python 爬取大樂透開獎結果

2021-09-20 21:49:10 字數 765 閱讀 3547

#coding=utf-8

#下面中文注釋不支援 所以開頭加 "#coding=utf-8"

# 獲取近期大樂透開獎結果, 並給出自己猜中的個數

import requests

# 這個api能夠免費得到近期開獎結果, url裡的-20代表獲取近20期的開獎資訊

url = ""

req = requests.get(url)

ret = req.json()

data = ret['data']

# 自己購買的號碼, 這裡是複式5+3

mycode = '01,02,03,04,05+01,02,03'

red,blue = mycode.split('+')

my_red = set(red.split(','))

my_blue = set(blue.split(','))

for d in data:

red,blue = d['opencode'].split('+')

open_red = set(red.split(','))

open_blue = set(blue.split(','))

red_count = len(open_red & my_red)#紅球命中的個數

blue_count = len(open_blue & my_blue)#籃球命中的個數

#輸出開獎情況, 和命中情況

print(f"期: -----+")

python爬取分析超級大樂透歷史開獎資料

博主作為爬蟲初學者,本次使用了requests和beautifulsoup庫進行資料的爬取 爬取 500彩票網 分析後發現 源 並非是通過頁面跳轉來查詢不同的資料,故可通過f12查詢network欄找到真正儲存所有歷史開獎結果的網頁 如圖 爬蟲部分 from bs4 import beautiful...

Scrapy爬取彩票開獎結果的實現

需求 爬取體育彩票高頻遊戲 北京11選5的開獎結果 實現計畫 使用scrapy從網頁上爬取 實現步驟 1 準備乙個開發測試環境,筆者使用的是 1 2 3 1 ubuntu16.04 2 python2.7.12 3 scrapy1.2.0 2 建立乙個scrapy工程 scrapy startpro...

爬取雙色球開獎

爬取雙色球開獎資訊 實驗目的 了解http.cookiejar和cookie,了解如何獲取瀏覽器的header。實驗要求 掌握如何獲取瀏覽器headers的方法。本實驗需要外網連線。實驗原理 http.cookiejar簡介 有的 特別像社交 需要登陸才能抓取到 的資料,那麼光模擬瀏覽器請求 內容是...