I want to get links for below web and stored in dataframe result_total, anyone can help ?
(currently, the code feedback a empty result_total)
And I ues for con in cons to retrieve contents in the linkage, is there other way can obtain them at one time ?
Thanks!
import requests
from bs4 import BeautifulStoneSoup
import pandas as pd
url='https://www.nowmsg.com/findzip/findzip.asp'
headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.60 Safari/537.36'}
web = requests.get(url,headers = headers)
soup = BeautifulStoneSoup(web.text)
cons = soup.findAll("div","col-md-3")
result_total= pd.DataFrame()
result_single= pd.DataFrame()
for con in cons:
con_1=con.find('a')
link= con_1.get('href')
text=con_1.text
result_single['link'] = link
result_single['state'] = text
result_total = result_total.append(result_single)