Parsing HTML

Discussion in 'PHP' started by bartolay13, Dec 12, 2010.

  1. #1
    bartolay13, Dec 12, 2010 IP
  2. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #2
    Try this :
    
    $ch=curl_init();
    curl_setopt($ch,CURLOPT_URL,'https://site.domain/page');
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,5);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    $buffer = curl_exec($ch);
    curl_close($ch);
    
    //$buffer contains the page's content
    
    PHP:
     
    tvoodoo, Dec 13, 2010 IP
  3. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #3
    used var_dump on $buffer it returns bool(false)
     
    bartolay13, Dec 13, 2010 IP
  4. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Well , tell me the page you are trying to parse... as it worked for the https page I've tested the code with...
     
    tvoodoo, Dec 13, 2010 IP
  5. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #5
    hmm... its not a possiblity, theres a user authentication on that page, and requires login. thanks for the info though.
     
    bartolay13, Dec 13, 2010 IP
  6. underground-stockholm

    underground-stockholm Guest

    Messages:
    53
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    cURL can also fetch URLs using authentication.
     
    underground-stockholm, Dec 13, 2010 IP
  7. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #7
    i asked about the host, it requires a proxy... ssl or socks, do you have any curl code that can connect behind proxy?
     
    bartolay13, Dec 14, 2010 IP
  8. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #8
    
    <?php
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://www.example.com');
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
    curl_setopt($ch, CURLOPT_PROXY, 'fakeproxy.com:1080');
    curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password');
    $data = curl_exec();
    curl_close($ch);
    ?>
    
    PHP:
     
    tvoodoo, Dec 14, 2010 IP
  9. kolucoms6

    kolucoms6 Active Member

    Messages:
    1,198
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #9
    Any Master here in simplehtmldom Object ??

    Need some Help ...
     
    kolucoms6, Jun 11, 2011 IP