0

i am trying to collect some data from a website , but it gives me not available in your country webpage. I tried using a proxy server from the same country but it didn't help. Here is my code

import urllib.request 
proxy_support = urllib.request.ProxyHandler({'http':'149.56.44.146:9201'}) 
opener = urllib.request.build_opener(proxy_support) 
urllib.request.install_opener(opener) 
with urllib.request.urlopen('http://www.seamless.com') as response:
  print(response​.read())

I don't know what's wrong here. Can someone help pls.

  • I tested your program and what you get isn't an "error" at all, it's just a page that says that (so you might want to edit that word). Having said that, I get the same message. Perhaps the proxy is also in a country that doesn't receive service? have you tried multiple proxies from different countries? – Ofer Sadan Aug 07 '17 at 07:30
  • I tried using a vpn and found out that it works in Usa and then i used a proxy server from usa and yeah i have tried a lot of usa proxies all leading to the same html page. – Vipul Bhardwaj Aug 07 '17 at 07:31
  • Edited thank you sir. – Vipul Bhardwaj Aug 07 '17 at 07:35
  • @Ofer Sadan , sir my problem is how to get the job done using proxy itself. – Vipul Bhardwaj Aug 07 '17 at 07:37
  • have a look at the answers for this: https://stackoverflow.com/questions/3168171/how-can-i-open-a-website-with-urllib-via-proxy-in-python because they use a different method to proxy than the one you use, check if that works – Ofer Sadan Aug 07 '17 at 07:39
  • Sir that's because its python3 that i am using and they use python2.7. The answer just below the one uses the same technique and the major issue is even though i use a proxy the website still doesn't give me complete access – Vipul Bhardwaj Aug 07 '17 at 07:57
  • Or just look up your IP when using the proxy in order to check if the proxy is working at all. – nostradamus Aug 07 '17 at 08:12
  • One advice: Use requests instead of Urllib. Requests more soft, more clever. Use headers (some sites recognize your country with headers (language etc)). – Attila Kis Aug 07 '17 at 08:23
  • I tried and the ip is same in both cases. But I don't understand why the proxy is not connecting – Vipul Bhardwaj Aug 07 '17 at 08:27

1 Answers1

0

you can use a module such as splash which has a proxy built-in, it can help you get past your country error problem

https://github.com/scrapinghub/splash

Anshul Sinha
  • 105
  • 1
  • 1
  • 10