代码拉取完成,页面将自动刷新
# coding:utf-8
from bs4 import BeautifulSoup as bs
import requests
import pm as pm
import json
import time
import re
import sys
# config配置
def go(i):
link = "https://www.57fx.com/file/" + str(i) + ".html"
ip = "10.12.345.892"
headers = {"CLIENT-IP": ip, "X-FORWARDED-FOR": ip}
response = requests.get(link, headers=headers)
html = response.text
soup = bs(html, "html.parser")
if len(soup.find_all("div", {"class": "content"})) != 0:
title = soup.find("div", {"class": "content"}).find("h1").get_text()
title = title.replace("'","\\'")
link = soup.find("a", {"class": "toyunDown"}).get('href')
link = link.replace("&third=0", "")
import datetime
nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') # 现在
arr = {}
arr['title'] = title
arr['link'] = link
arr['createtime'] = nowTime
arr['updatetime'] = nowTime
arr['key_id'] = 'pk_'+str(i)
map = {}
map['link'] = link
count = pm.getcount('pan', map)
if count == 0:
pm.insert('pan', arr)
def start():
for i in range(300000, 310000):
print(i)
if i % 50 == 0:
time.sleep(2)
go(i)
start()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。