当前位置 博文首页 > LY的博客:使用REQUESTS和BS4 爬取全国银行的联行号,物理地址,

    LY的博客:使用REQUESTS和BS4 爬取全国银行的联行号,物理地址,

    作者:[db:作者] 时间:2021-08-09 18:51

    from bs4 import BeautifulSoup
    import requests
    n=1
    url='http://www.5cm.cn/bank/'+str(n)
    
    header={'user-agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.XXXX.XXX Safari/537.36'}
    for i in range (1,10000):
        html=requests.get(url,headers=header).text
        #print (html)
        soup=BeautifulSoup(html,'lxml') #用BeautifulSoup来解析获取的子页面html代码
    
        for k in soup.find_all ('tr')[1:]:
            print (k)
        print ('--')
        list1=[]
        for j in soup.select('tr td'):
            list1.append(j.get_text())
        print (list1)
     

    ?

    cs