Q:

Using python to scrape contents of jsp webpage

Using Python and the requests library, I have a list of zip codes, and from these I would like to compile a list of nearby CVS store addresses for each.   I can extract the address field without a problem, but I cannot dynamically generate the next page since there is no "&zip=77098" (or equivalent) in the URL.   Each time I visit the page I get a seemingly random "requestid" value.  
http://www.cvs.com/store-locator/store-locator-landing.jsp?_requestid=1003175
If I copy this link and paste in another browser it routes me back to my default CVS location.   Is there a way to send the zip code in the URL or otherwise dynamically set the location to search for?    
This is my (not working) code for one zip code.   It returns the "default" locations, not the locations specific to the zip in in the header:
data = {"search":"77098"}
urlx = 'http://www.cvs.com/store-locator/store-locator-landing.jsp'
cookies = requests.get(urlx).cookies

rx = requests.post(urlx, cookies=cookies,data=data, headers={'user-agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'})

soupx = BeautifulSoup(rx.content, "lxml-xml")
addressList = soupx.findAll("div", { "class" : "address-wrap" })
distanceList = soupx.findAll("span", { "class" : "store-miles" })

A:

There quite a bit whole to going on, first you need to get the coordinates for the zip code you enter so you can use them later to post to the url the gives you the search results:
urlx = 'http://www.cvs.com/store-locator/store-locator-landing.jsp'
headers = {
    'user-agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'}

# params for get request to get coordinates for later post.  
coord_params = { "output": "json",
                "key": "AkezKYdo-i6Crmr6nW9y0Ce_72T-osA8SwDdbgvfMSrKL47FVwQOpjBRGW_ON5Aq",
                "$filter": "Cvs_Store_Flag Eq 'Y'"}

# This provides the coordinates. 
coords_url = "https://dev.virtualearth.net/REST/v1/Locations"

# The post to get the actual results is to this url.     
post = "https://www.cvs.com/rest/bean/cvs/store/CvsStoreLocatorServices/getSearchStore"

zipcode = "77098"
# Template to pass each zip to in your actual loop. 
template = "{zipcode},US"

with requests. Session() as s:
    s.get(urlx)
    # Add the query param passing in each zipcode
    coord_params["query"] = template.format(zipcode=zipcode)
    js = s.get(coords_url, params=coord_params).json()
    # Parse latitude and longitude from the returned json. 
    latitude, longitude =(js[u'resourceSets'][0][u'resources'][0]["point"][u'coordinates'])
     # finally get the  search results. 
    results = s.post(post, data={"latitude": latitude, "longitude":longitude}).json()

 from pprint import pprint as pp
 pp(results)

Output:
{u'atgResponse': {u'sc': u'00',
                  u'sd': [{u'ad': u'2111 W. ALABAMA STREET',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'0.35',
                           u'id': u'10554',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-874-1085',
                           u'sn': u'MyWeeklyAdStore10554',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77098'},
                          {u'ad': u'4700 KIRBY DRIVE',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'0.43',
                           u'id': u'5685',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-533-2200',
                           u'sn': u'MyWeeklyAdStore5685',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77098'},
                          {u'ad': u'2910 WESTHEIMER ROAD',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'0.69',
                           u'id': u'7126',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-526-0062',
                           u'sn': u'MyWeeklyAdStore7126',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77098'},
                          {u'ad': u'6011 KIRBY DRIVE',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'1.17',
                           u'id': u'7479',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-522-3983',
                           u'sn': u'MyWeeklyAdStore7479',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77005'},
                          {u'ad': u'1003 RICHMOND AVENUE',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'1.41',
                           u'id': u'7162',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-807-8491',
                           u'sn': u'MyWeeklyAdStore7162',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77006'},
                          {u'ad': u'1001 WAUGH DRIVE, CORNER OF DALLAS AVENUE',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'1.87',
                           u'id': u'5840',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-807-7859',
                           u'sn': u'MyWeeklyAdStore5840',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77019'},
                          {u'ad': u'2266 WEST HOLCOMBE BOULEVARD',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'1.93',
                           u'id': u'5833',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-218-2180',
                           u'sn': u'MyWeeklyAdStore5833',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77030'},
                          {u'ad': u'4323 SAN FELIPE ST',
                           u'ci': u'HOUSTON',
                           u'cv': u'',
                           u'cz': u'',
                           u'dt': u'2.23',
                           u'id': u'16368',
                           u'nv': u'',
                           u'nz': u'',
                           u'ph': u'713-331-0166',
                           u'sn': u'MyWeeklyAdStore16368',
                           u'st': u'TX',
                           u'wf': u'N',
                           u'zp': u'77027'},
                          {u'ad': u'1000 ELGIN STREET',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'2.32',
                           u'id': u'784',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-526-4478',
                           u'sn': u'MyWeeklyAdStore784',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77004'},
                          {u'ad': u'5401 WASHINGTON AVENUE',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'2.46',
                           u'id': u'7476',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-861-3883',
                           u'sn': u'MyWeeklyAdStore7476',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77007'},
                          {u'ad': u'3939 BELLAIRE BOULEVARD',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'2.54',
                           u'id': u'6240',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'832-778-9025',
                           u'sn': u'MyWeeklyAdStore6240',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77025'},
                          {u'ad': u'4755 WESTHIEMER ROAD',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'2.58',
                           u'id': u'2988',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-386-1091',
                           u'sn': u'MyWeeklyAdStore2988',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77027'},
                          {u'ad': u'402 GRAY STREET',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'2.59',
                           u'id': u'5968',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-982-5527',
                           u'sn': u'MyWeeklyAdStore5968',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77002'},
                          {u'ad': u'7900 SOUTH MAIN',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'2.77',
                           u'id': u'7402',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-660-8934',
                           u'sn': u'MyWeeklyAdStore7402',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77030'},
                          {u'ad': u'8500 MAIN ST',
                           u'ci': u'HOUSTON',
                           u'cv': u'',
                           u'cz': u'',
                           u'dt': u'2.9',
                           u'id': u'16676',
                           u'nv': u'',
                           u'nz': u'',
                           u'ph': u'713-661-8213',
                           u'sn': u'MyWeeklyAdStore16676',
                           u'st': u'TX',
                           u'wf': u'N',
                           u'zp': u'77025'},
                          {u'ad': u'5204 RICHMOND AVENUE',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'3.14',
                           u'id': u'3177',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-961-0874',
                           u'sn': u'MyWeeklyAdStore3177',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77056'},
                          {u'ad': u'2580 SHEARN ST',
                           u'ci': u'HOUSTON',
                           u'cv': u'',
                           u'cz': u'',
                           u'dt': u'3.26',
                           u'id': u'17181',
                           u'nv': u'',
                           u'nz': u'',
                           u'ph': u'713-331-0377',
                           u'sn': u'MyWeeklyAdStore17181',
                           u'st': u'TX',
                           u'wf': u'N',
                           u'zp': u'77007'},
                          {u'ad': u'5402 WESTHEIMER ROAD',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'3.39',
                           u'id': u'7753',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-877-1479',
                           u'sn': u'MyWeeklyAdStore7753',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77056'},
                          {u'ad': u'917 MAIN STREET',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'3.4',
                           u'id': u'6834',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-982-5565',
                           u'sn': u'MyWeeklyAdStore6834',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77002'},
                          {u'ad': u'9838 BUFFALO SPEEDWAY',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'3.9',
                           u'id': u'5258',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-218-4491',
                           u'sn': u'MyWeeklyAdStore5258',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77025'},
                          {u'ad': u'3811 OLD SPANISH TRAIL',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'3.95',
                           u'id': u'7198',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-741-7900',
                           u'sn': u'MyWeeklyAdStore7198',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77021'},
                          {u'ad': u'5430 BISSONNET STREET, CORNER OF CHIMNEY ROCK, CORNER OF CHIMNEY ROCK',
                           u'ci': u'BELLAIRE',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'4.2',
                           u'id': u'5273',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-218-2291',
                           u'sn': u'MyWeeklyAdStore5273',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77401'},
                          {u'ad': u'300 MEYERLAND PLAZA MALL',
                           u'ci': u'HOUSTON',
                           u'cv': u'',
                           u'cz': u'',
                           u'dt': u'4.33',
                           u'id': u'17091',
                           u'nv': u'',
                           u'nz': u'',
                           u'ph': u'713-292-0031',
                           u'sn': u'MyWeeklyAdStore17091',
                           u'st': u'TX',
                           u'wf': u'N',
                           u'zp': u'77096'},
                          {u'ad': u'110 WEST 20TH STREET',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'4.87',
                           u'id': u'7092',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'832-673-7131',
                           u'sn': u'MyWeeklyAdStore7092',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77008'},
                          {u'ad': u'6545 WESTHEIMER ROAD',
                           u'ci': u'HOUSTON',
                           u'cv': u'I',
                           u'cz': u'',
                           u'dt': u'5.12',
                           u'id': u'5895',
                           u'nv': u'I',
                           u'nz': u'',
                           u'ph': u'713-243-8050',
                           u'sn': u'MyWeeklyAdStore5895',
                           u'st': u'TX',
                           u'wf': u'Y',
                           u'zp': u'77057'}]}}

There is a call to https://dev.virtualearth.net/REST/v1/Locations which is a Bing maps Microsoft api, I suggest you setup an account and create your own application which will allow you a key, it took literally two minutes for me to do it.  As far as I know the free limit is 30k requests per day so that should be more than enough.