0

I have a working php code that extracts links but my problem is i don't know how to convert it into a VB.net code as VB.net does not use CURL. Is there any way to convert this? Thanks in advance.

My code:

$npages=100;
$gg_url = 'http://www.google.com/search?hl=en&q=' . urlencode(test) . '&filter=0&start=';
$i=1;
$size=0;

$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_COOKIEFILE => "cookie.txt",
CURLOPT_COOKIEJAR => "cookie.txt",
CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3",
CURLOPT_REFERER => "http://www.google.com/",
);

    for ($page = $start; $page < $npages; $page++)
    {
        $ch = curl_init($gg_url.$page.'0');
        curl_setopt_array($ch,$options);
        $scraped="";
        $scraped.=curl_exec($ch);
        curl_close( $ch );
        $results = array();
        preg_match_all('/a href="([^"]+)" class=l.+?>.+?<\/a>/',$scraped,$results);
        foreach ($results[1] as $url)
        {
        echo "<a href='$url'>$url</a> <br>";
        $i++;
        }
        $size+=strlen($scraped);
    }

echo "Number of results: $i Total KB read: ".($size/1024.0);

1 Answer 1

1

Use a WebClient object. You should be able to do the same with that guy: http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.