How to Connect to a Tor Hidden Service Using Curl in PHP

PHP cURL over TOR what am I doing wrong?

Tor browser by default uses port 9150 for SOCKS, where the default for the Tor daemon on Linux or the Expert Bundle on Windows is 9050.

If you change to port 9150 you should successfully be able to relay through Tor.

How to access onion sites from php curl?

Well, I've found out that I need to set proxy type to CURLPROXY_SOCKS5_HOSTNAME:

curl_setopt($ch, CURLOPT_PROXYTYPE, 7);

It works fine.

Route cURL requests through Tor network

You can use torify.

As per https://linuxaria.com/howto/how-to-anonymize-the-programs-from-your-terminal-with-torify:

torify is a simple wrapper that attempts to find the best underlying
Tor wrapper available on a system. It calls torsocks or tsocks with a
tor specific configuration file.

torify curl OtherSite.com/myfile.xml

Can't get website meta description over tor network using PHP

You may use DOMDocument to do the data parsing (I've tested in my server and it works):

Please replace:

$tags = get_meta_tags($response);
echo $tags['description']; // a php manual

by


//parsing begins here:
$doc = new DOMDocument();
@$doc->loadHTML($response);

$metas = $doc->getElementsByTagName('meta');

for ($i = 0; $i < $metas->length; $i++)
{
$meta = $metas->item($i);
if(strtolower($meta->getAttribute('name')) == 'description')
$description = $meta->getAttribute('content');
if(strtolower($meta->getAttribute('name')) == 'keywords')
$keywords = $meta->getAttribute('content');
}

echo "Description: $description". '<br/><br/>';
echo "Keywords: $keywords";



Related Topics



Leave a reply



Submit