1 Star 0 Fork 185

Djoy / Python爬虫

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
爬取我主良缘相亲网.py 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
import requests
import pymongo
import json
import random
import time
from fake_useragent import UserAgent
clien=pymongo.MongoClient(host='改成自己的数据库')
db=clien.Blind_date_information
coll=db.text
ua=UserAgent()
headers={
'User-Agent':ua.random
}
def request_page_html(page):
URL='http://www.7799520.com/api/user/pc/list/search?marry=1&page={}'.format(page)
try:
sponse=requests.get(URL,headers=headers)
return json.loads(sponse.text)
except Exception:
print('request error')
def extract_Json(json):
if json:
jsons=json.get('data').get('list')
for i in jsons:
data={}
data['相亲人的照片']=i.get('avatar')
data['出生年月']=i.get('birthdayyear')
data['学历']=i.get('education')
data['独白']=i.get('monolog')
data['网站中的网名']=i.get('username')
data['UserID']=i.get('userid')
data['所在省份']=i.get('province')
data['所在城市']=i.get('city')
data['身高']=i.get('height')
data['性别(1代表男 2代表女)']=i.get('gender')
coll.insert_one(data)
print(data)
#一共2872页
#print(request_page_html(2872))
#extract_Json(request_page_html(1))
for i in range(1,2873):
extract_Json(request_page_html(i))
Python
1
https://gitee.com/FXjoy/python_reptilian.git
git@gitee.com:FXjoy/python_reptilian.git
FXjoy
python_reptilian
Python爬虫
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891