Добрый день всем. Я пробую прочитать сайт http://primgazeta.ru/rss/ программой: import cookielib hdr = {'User-Agent': ‘Magic Browser’, ‘Set-cookie’: ‘beget=begetok; expires=expstr; path=“/”’} hdr = ‘beget=begetok; expires=’+expires+'; path=“/”' req = urllib2.Request(url, headers=hdr) try: page = urllib2.urlopen(req) print page.info() except urllib2.HTTPError, e: print e.fp.read() html = page.read() print html return html; и получаю
Тогда я попробовал так: from urllib2 import Request, build_opener, HTTPCookieProcessor, HTTPHandler import cookielib import js2py def getHtmlCook(url, expires): import cookielib cook = ‘beget=begetok; expires=’+expires+'; path=“/”' cj = cookielib.CookieJar() opener = build_opener(HTTPCookieProcessor(cj)) opener.addheaders.append(('Cookie', cook)) try: page = opener.open(url) print page.info() except urllib2.HTTPError, e: print e.fp.read() html = page.read() print html return html; js = “”“ function set_expires() { var now = new Date() var time = now.getTime() time += 19360000 * 1000 now.setTime(time) return now.toUTCString() } set_expires() ”“” result = js2py.eval_js(js) + ‘ GMT’ xml = getHtmlCook('http://primgazeta.ru/rss/', result) print xml и получил тот же ответ. Подскажите, пожалуйста, что делаю не так и что надо сделать, чтобы получить нормальный xml. (Хотелось бы конкретный код.) Заранее спасибо всем.