日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人文社科 > 生活经验 >内容正文

生活经验

Python爬取4399好wan的小游戏!

發(fā)布時(shí)間:2023/11/27 生活经验 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python爬取4399好wan的小游戏! 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
#coding=utf-8
#爬取4399所有好玩的游戲
import re
import os
import requests# 基礎(chǔ)url
host_url = 'http://www.4399.com'
swfbase_url = 'http://sda.4399.com/4399swf'  
hw_url = 'http://www.4399.com/flash/gamehw.htm'if not os.path.exists('./swf'):os.mkdir(r'./swf')# 需要的正則表達(dá)式
tmp_pat = re.compile(r'<ul class="tm_list">(.*?)</ul>',re.S)
game_pat = re.compile( r'<li><a href="(/flash.*?)"><img alt=.*?src=".*?"><b>(.*?)</b>.*?</li>', re.S )
swf_pat = re.compile(r'_strGamePath="(.*?swf)"',re.S)game_html = requests.get(hw_url)
game_html.encoding = 'gb2312'tt = tmp_pat.search(game_html.text,re.S).group(1)game_list = game_pat.findall(tt)for l in game_list:# print l[0], l[1]game_page = requests.get(host_url + l[0]).textsrc_url = swf_pat.search(game_page)if src_url == None:continue;src = requests.get( swfbase_url + src_url.group(1) ).contentprint ("正在保存游戲:" , l[1] )open( "./swf/"+ l[1] + ".swf", "wb" ).write( src )

轉(zhuǎn)載于:https://www.cnblogs.com/N-S-P/p/11520534.html

總結(jié)

以上是生活随笔為你收集整理的Python爬取4399好wan的小游戏!的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。