post - Issue with cookies during webpage parsing using Python -
i trying parse webpage using python.
problem: page requires me enter zipcode in prompt window before loading. if don't enter zipcode (parse webpage directly) webpage gets loaded has 1 data table missing in it.
moment enter zipcode, page reloads in response without missing out data table.
i using following code accomplish same:
from requests import session import urllib, urllib2, cookielib payload = { '/att/ecom/shop/view/localizationformhandler.localizationinputbean.errorurl':'/shop/wireless/plans/prepaidplans.changezipmodalresponse.xhr.html', '/att/ecom/shop/view/localizationformhandler.localizationinputbean.skuid':'', '/att/ecom/shop/view/localizationformhandler.localizationinputbean.successurl':'/shop/wireless/plans/prepaidplans.changezipmodalresponse.xhr.html', '/att/ecom/shop/view/localizationformhandler.localize':'', '/att/ecom/shop/view/localizationformhandler.localize.x':'34', '/att/ecom/shop/view/localizationformhandler.localize.y':'13.566665649414062', '/att/ecom/shopcore/bean/localizationdatabean.localizationoriginatingpage':'/shop/wireless/plans/prepaidplans.html', '_d:/att/ecom/shop/view/localizationformhandler.localizationinputbean.errorurl':' ', '_d:/att/ecom/shop/view/localizationformhandler.localizationinputbean.skuid':' ', '_d:/att/ecom/shop/view/localizationformhandler.localizationinputbean.successurl':' ', '_d:/att/ecom/shop/view/localizationformhandler.localize':' ', '_d:/att/ecom/shopcore/bean/localizationdatabean.localizationoriginatingpage':' ', '_d:zipcode':' ', '_dargs':'/shop/wireless/plans/prepaidplans.changezipmodal.html', '_dynsessconf':'23', '_dyncharset':'utf-8', 'zipcode':'10001' } session() c: c.post('http://www.att.com/shop/wireless/plans/prepaidplans.changezipmodal.html', data=payload) request = c.get('http://www.att.com/shop/wireless/plans/prepaidplans.html') #print request.headers #print request.text att = open('att.html','wb') att.write(request.text) ` pleas me in resolving issue , pardon ignorance new programming.
Comments
Post a Comment