当前位置 博文首页 > python爬取分析超级大乐透历史开奖数据第1/2页

    python爬取分析超级大乐透历史开奖数据第1/2页

    作者:神拳小江南阿 时间:2021-07-21 18:43

    博主作为爬虫初学者,本次使用了requests和beautifulsoup库进行数据的爬取

    爬取网站:http://datachart.500.com/dlt/history/history.shtml —500彩票网
    (分析后发现网站源代码并非是通过页面跳转来查找不同的数据,故可通过F12查找network栏找到真正储存所有历史开奖结果的网页)

    如图:

    在这里插入图片描述

    爬虫部分

    from bs4 import BeautifulSoup #引用BeautifulSoup库
    import requests     #引用requests
    import os      #os
    import pandas as pd
    import csv
    import codecs
    
    lst=[]
    url='http://datachart.500.com/dlt/history/newinc/history.php?start=07001&end=21018'
    r = requests.get(url)      
    r.encoding='utf-8'
    text=r.text
    soup = BeautifulSoup(text, "html.parser")
    tbody=soup.find('tbody',)
    tr=tbody.find_all('tr')
    td=tr[0].find_all('td')
    for page in range(0,14016):
     td=tr
                                
    12下一页阅读全文
    jsjbwy
    下一篇:没有了