爬取某某共享游戏排行榜
import requests
import re

for i in range(1,50):
url="http://www.yx7088.com/gamelist/index.html?&p={0}".format(i)
headers = {\’user-agent\’: \’Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36\’}
a = requests.get(url, headers=headers)
a.encoding = \’utf-8\’
bb = re.compile(\'<em>.*?<a.*?>(.*?)</a>\’, re.S)
position=re.findall(bb,a.text)
print(position)
with open("Steam.txt", "a", encoding="utf-8") as f:
for positions in position:
f.write(positions + "\\n")