Tell me, comrades, why seemingly identical code fragments behave differently. Is the search page on the yandex site opened and saved to a file, and the main page on the moyareklama site?
import urllib base = "http://www.moyareklama.ru/single_ad_new.php?" data = {"id":"201623465"} url = base + urllib.urlencode(data) print url page = urllib.urlopen(url).read() f = open ("1.html", "w") f.write(page) f.close() print page ##base = "http://yandex.ru/yandsearch?" ##data = (("text","python"),("lr","192")) ##url = base + urllib.urlencode(data) ##print url ##page = urllib.urlopen(url).read() ##f = open ("1.html", "w") ##f.write(page) ##f.close() ##print page
Cookie doesn't work either ...
import requests url = "http://www.moyareklama.ru/" r = requests.get(url) cookies = r.cookies payload = {"id":"201686924"} url = "http://www.moyareklama.ru/single_ad_new.php" s = requests.get(url, params = payload, cookies = cookies) print cookies print s.url ##print s.text