from bs4 import BeautifulSoup
import requests

cities = ['01','02','03','04','05','06','07','08','10','11','12','13','15','16','17','18']
URL ='http://www.aepb.gov.cn:8080/WRYJG/STZXGK/'
session = requests.Session()
outfile = open("anhui_info.txt", "w")

starterURL = URL + 'STindex.aspx?dsid=34{}00000000'
for city in cities:
    url = starterURL.format(city)
    req = session.get(url)
    soup = BeautifulSoup(req.text, "lxml")
    links = soup.select("div [class~=jc_list] ul a")
    for link in links:
        entURL = URL + link['href']
        outfile.write(link.string) # entname
        req2 = session.get(entURL)
        soup2 = BeautifulSoup(req2.text, "lxml")
        autoURL = URL + soup2.select('span dd a')[-1]['href']
        outfile.write(" " + autoURL) # auto url
        req3 = session.post(autoURL)
        soup3 = BeautifulSoup(req3.text, "lxml")
        options = soup3.find_all('option')
        for option in options: # all stations
            outfile.write(" " + option['value'])
        outfile.write("\n")

outfile.close()
005c9e1ed9a6203dd2e6a1092ea82b8c3736d3f3
<mask token>

<mask token>
for city in cities:
    url = starterURL.format(city)
    req = session.get(url)
    soup = BeautifulSoup(req.text, 'lxml')
    links = soup.select('div [class~=jc_list] ul a')
    for link in links:
        entURL = URL + link['href']
        outfile.write(link.string)
        req2 = session.get(entURL)
        soup2 = BeautifulSoup(req2.text, 'lxml')
        autoURL = URL + soup2.select('span dd a')[-1]['href']
        outfile.write(' ' + autoURL)
        req3 = session.post(autoURL)
        soup3 = BeautifulSoup(req3.text, 'lxml')
        options = soup3.find_all('option')
        for option in options:
            outfile.write(' ' + option['value'])
        outfile.write('\n')
outfile.close()

<mask token>
cities = ['01', '02', '03', '04', '05', '06', '07', '08', '10', '11', '12',
    '13', '15', '16', '17', '18']
URL = 'http://www.aepb.gov.cn:8080/WRYJG/STZXGK/'
session = requests.Session()
outfile = open('anhui_info.txt', 'w')
starterURL = URL + 'STindex.aspx?dsid=34{}00000000'
for city in cities:
    url = starterURL.format(city)
    req = session.get(url)
    soup = BeautifulSoup(req.text, 'lxml')
    links = soup.select('div [class~=jc_list] ul a')
    for link in links:
        entURL = URL + link['href']
        outfile.write(link.string)
        req2 = session.get(entURL)
        soup2 = BeautifulSoup(req2.text, 'lxml')
        autoURL = URL + soup2.select('span dd a')[-1]['href']
        outfile.write(' ' + autoURL)
        req3 = session.post(autoURL)
        soup3 = BeautifulSoup(req3.text, 'lxml')
        options = soup3.find_all('option')
        for option in options:
            outfile.write(' ' + option['value'])
        outfile.write('\n')
outfile.close()

from bs4 import BeautifulSoup
import requests
cities = ['01', '02', '03', '04', '05', '06', '07', '08', '10', '11', '12',
    '13', '15', '16', '17', '18']
URL = 'http://www.aepb.gov.cn:8080/WRYJG/STZXGK/'
session = requests.Session()
outfile = open('anhui_info.txt', 'w')
starterURL = URL + 'STindex.aspx?dsid=34{}00000000'
for city in cities:
    url = starterURL.format(city)
    req = session.get(url)
    soup = BeautifulSoup(req.text, 'lxml')
    links = soup.select('div [class~=jc_list] ul a')
    for link in links:
        entURL = URL + link['href']
        outfile.write(link.string)
        req2 = session.get(entURL)
        soup2 = BeautifulSoup(req2.text, 'lxml')
        autoURL = URL + soup2.select('span dd a')[-1]['href']
        outfile.write(' ' + autoURL)
        req3 = session.post(autoURL)
        soup3 = BeautifulSoup(req3.text, 'lxml')
        options = soup3.find_all('option')
        for option in options:
            outfile.write(' ' + option['value'])
        outfile.write('\n')
outfile.close()

from bs4 import BeautifulSoup
import requests

cities = ['01','02','03','04','05','06','07','08','10','11','12','13','15','16','17','18']
URL ='http://www.aepb.gov.cn:8080/WRYJG/STZXGK/'
session = requests.Session()
outfile = open("anhui_info.txt", "w")

starterURL = URL + 'STindex.aspx?dsid=34{}00000000'
for city in cities:
    url = starterURL.format(city)
    req = session.get(url)
    soup = BeautifulSoup(req.text, "lxml")
    links = soup.select("div [class~=jc_list] ul a")
    for link in links:
        entURL = URL + link['href']
        outfile.write(link.string) # entname
        req2 = session.get(entURL)
        soup2 = BeautifulSoup(req2.text, "lxml")
        autoURL = URL + soup2.select('span dd a')[-1]['href']
        outfile.write(" " + autoURL) # auto url
        req3 = session.post(autoURL)
        soup3 = BeautifulSoup(req3.text, "lxml")
        options = soup3.find_all('option')
        for option in options: # all stations
            outfile.write(" " + option['value'])
        outfile.write("\n")

outfile.close()