Request from another IP address of the country

I would like to view the contents of a movie from another country in the Playstation store. However, the playstation store blocks IP based on the location of the request, so a movie in Canada cannot be viewed from the USA:

https://store.playstation.com/#!/en-ca/movies/the-house/cid=UV0130-NPVA92773_CN-0000000000236063

Is there a way to do something like the following:

url = 'https://store.playstation.com/#!/en-ca/movies/the-house/cid=UV0130-NPVA92773_CN-0000000000236063' r = requests.get(url, proxy_from = COUNTRY['CA']) # In pseudocode 

Basically, so that you can specify the country, and then send a request from the IP address, which will be recognized as arriving from this country. How will this be done?

+6
source share
2 answers

If I understand correctly, you are basically asking how to make url request in python using proxy?

If so, you can do it as follows:

 import urllib2 import urllib import random CAproxies = [{"http":"199.201.122.175:3128", "https":"199.201.122.175:3128"},{"http":"192.99.3.129:3128", "https":"192.99.3.129:3128"},{"http":"192.99.246.101:8118", "https":"192.99.246.101:8118"},{"http":"205.205.129.130:443", "https":"205.205.129.130:443"} ] proxies = urllib2.ProxyHandler(random.choice(CAproxies)) url = 'https://store.playstation.com/#!/en-ca/movies/the-house/cid=UV0130-NPVA92773_CN-0000000000236063' request = urllib2.Request(url) request.add_header("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0") request.add_header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") opener = urllib2.build_opener(proxies) urllib2.install_opener(opener) r = urllib2.urlopen(request, timeout=15) html = r.read() 

The headings are good if you want the service to think that you are using a browser, they usually have protection against bots. You need to replace the proxy address with your own proxy server, this is just an invented proxy for illustration.

The list of proxies can be found here, for example: http://www.proxy-listen.de/Proxy/Proxyliste.html In case the above proxy does not work. In case one of the proxies works best for your specific location (let's say that the second one works best for you, it might be a good idea to change the random proxy selection only to the second one. Ie

 random.choice(CAproxies) -> CAproxies[1] 

CAproxies [3] works best for me. The first 250 characters from html:

 >>> html[0:250] '<!DOCTYPE html>\n\n<html class="ctry mobvportA rgba">\n <head>\n <meta http-equiv="x-ua-compatible" content="IE=edge" />\n <meta charset="utf-8"/>\n\n <link rel="dns-prefetch" href="//ajax.googleapis.com">\n <link rel="dns-prefetch" href="//ssl.' 
+2
source

Something you can do is simply diagnose and try to figure out if this is possible at all.

The first thing you can do is use a VPN or any Proxy to simulate your location coming from Canada. If this works, and you can load the desired page, then most likely the location is determined by the IP address of the request.

And in fact, from the point of view of the service, in your case, the Playstation store does not have other reliable information to extract the client’s geolocation from.

So, if so, the only reasonable solution to your problem would be to change your IP address in some way. But in any case, if you do this from the side of your application, there will be too many layers, for example. routers, which in any case will reveal your real location, since the final IP packet that reaches the service will contain a real real IP .

Thus, this has nothing to do with your application or client request, you should think about what to put in front of it.

So if your question is:

How to achieve my goal on the application side?

... then the answer: most likely there is no way: /

But if you ask:

How can I achieve my goal?

... then there are options:

  • Use a Proxy or VPN . You will definitely find a VPN service that will provide access credentials (for example, OpenVPN config ) for each location, so you can download them programmatically. This can be implemented on the side of your application.
  • And reckless ... there are cars in every place you want to request :)
0
source

Source: https://habr.com/ru/post/987388/


All Articles