Can I Use Requests.post To Submit A Form?
I am trying to get the list of stores from this site: http://www.health.state.mn.us/divs/cfh/wic/wicstores/ I'd like to get the list of stores that is produced when you click on th
Solution 1:
Try the below code to populate the result, if you considered to select view all stores option.
import requests
from bs4 import BeautifulSoup
FormData={
    'submitAllStores':'View All Stores'
}
with requests.Session() as s:
    s.headers = {"User-Agent":"Mozilla/5.0"}
    res = s.post("http://www.health.state.mn.us/divs/cfh/wic/wicstores/index.cfm",data=FormData)
    soup = BeautifulSoup(res.text, 'lxml')
    for item in soup.select(".info"):
        shopname = item.select_one(".info-service").text
        print(shopname)
Partial output:
1st Quality Market
33rd Meat & Grocery
52 Market  And Trading
75 Market And Deli
7th Grocery
9th Ave X-Press
Post a Comment for "Can I Use Requests.post To Submit A Form?"