Note that there are some explanatory texts on larger screens.

plurals
  1. POCURLOPT_FOLLOWLOCATION not working
    primarykey
    data
    text
    <p>I'm trying to scrape the data at this link: <a href="http://www.treasurydirect.gov/NP/BPDLogin?application=np" rel="nofollow">http://www.treasurydirect.gov/NP/BPDLogin?application=np</a></p> <p>which contains a meta refresh.</p> <p>I'm using curl_exec with CURLOPT_FOLLOWLOCATION set to true.</p> <p>In phpinfo() I confirmed that safe mode and basedir are not set. However CURLOPT_FOLLOWLOCATION is still not working. Here's my code:</p> <pre><code>&lt;?php error_reporting(E_ALL); $url = 'http://www.treasurydirect.gov/NP/BPDLogin?application=np'; // READ THE WEB PAGE $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,20); curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true); curl_setopt($ch,CURLOPT_COOKIEFILE,"cookies.txt"); curl_setopt($ch,CURLOPT_COOKIEJAR,"cookies.txt"); curl_error($ch); $htm = curl_exec($ch); curl_close($ch); // MAKE OUR OUTPUT EASY TO READ echo "&lt;pre&gt;"; // GET THE TITLE $txt = strip_tags($htm, '&lt;title&gt;'); $rgx = '#' // REGEX DELIMITER - START . '\&lt;title\&gt;' // TITLE TAG WITH ANGLE BRACKETS ESCAPED - START . '(.*?)' // GROUP OF ANYTHING . '\&lt;/title\&gt;' // TITLE TAG WITH ANGLE BRACKETS ESCAPED - END . '#' // REGEX DELIMITER - END . 'is' // CASE-INSENSITIVE, SINGLE LINE ; preg_match($rgx, $txt, $arr); // DISPLAY THE TITLE echo '&lt;strong&gt;' . $arr[1] . '&lt;/strong&gt;' . PHP_EOL . PHP_EOL ; // SHOW THE PAGE SOURCE $src = htmlentities($htm); echo $src; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload