还有一个多小时 双十一了.我喜欢的女孩子还是不喜欢我....注定单身无疑
ps:本文不是一个技术贴.爬虫也只是花半个小时写出来的,程序逻辑非常不严谨......本文也不讲解技爬虫术细节
ps:本文不是一个技术贴.爬虫也只是花半个小时写出来的,程序逻辑非常不严谨......本文也不讲解技爬虫术细节
ps:本文不是一个技术贴.爬虫也只是花半个小时写出来的,程序逻辑非常不严谨......本文也不讲解技爬虫术细节
非常喜欢简书上的文艺女孩子,真的不知道如何才能快速获取妹子的联系方式.............
准备:
1.python3.x运行环境 (requests,BeautifulSoup,pymongo) 提前安装
2.mongo db (db jianshu)
3.一枚简书妹子的userid
下载项目地址
https://gitee.com/dishenghk/PaChong
填入妹子的userid
image.pngstart([user_id'])
start
python setup.py
image.png
然后妹子 就入库啦...
image.png
妹子有在微信留微信的 ,会标1
ps:自动识别男女.不用担心是个抠脚大汉...好了还剩最后一个小时,我要给喜欢的女孩子去表白了.
# -*- coding: UTF-8 -*-
from robot import Robot
from pymongo import *
conn=MongoClient("localhost", 27017)
host="http://www.jianshu.com"
# myUserUrl="http://www.jianshu.com/users/a47b65385096/following"
# #实例化机器人
# robot=Robot(myUserUrl,conn)
# #机器人开启工作
# robot.start()
count =0
def start(urls):
global count
for url in urls:
url_add="http://www.jianshu.com/users/"+url+"/following"
robot=Robot(url_add,conn)
newUrl=robot.start()
#去重
if len(newUrl):
del newUrl[0]
#print(newUrl)
if len(newUrl):
count=count+1
if count>=20:
break
print("第"+str(count)+"个妹子")
start(newUrl)
start(['a47b65385096'])
# -*- coding: UTF-8 -*-
import requests
import re
from bs4 import BeautifulSoup
from bs4 import element
class Robot:
# 传入机器人需要去爬取的页面
def __init__(self,url,conn):
print("实例化机器人成功,检测地址为:"+ url)
self.url=url
self.conn=conn
# 抓取页面内容并构建beautifulsoup实例对象
def request(self):
print("开始获取文档内容")
self.html=requests.get(self.url)
self.htmlForSoup=BeautifulSoup(self.html.text,"html.parser")
#检查是否是女性
def checkIfFemale(self):
#看简书设置是女孩子
print("检查是否为女性")
i=self.htmlForSoup.select(".title > i")
if len(i):
item=i[0]
if item['class'][1]=="ic-woman":
print("发现一个妹子!")
return True
elif item['class'][1]=='ic-man':
print("是个汉子,不深入了")
return False
else:
print("性别未知...继续深入")
#如果简述设置不是一个女孩子那么深入检查有没有女孩子的特征
#首先看简介
introduce=self.htmlForSoup.find('div',class_="js-intro")
if not introduce:
return False
for text in introduce.contents:
if(isinstance(text,element.NavigableString)):
if re.search('女',text.string):
print("发现啦,真的是个妹子")
return True
#然后看名字
name=self.htmlForSoup.select('.title > .name ')
if len(name):
item=name[0]
if item.string:
if re.search('女',item.string):
return True
print("丫的,男的")
return False
def checkIfHasWeixin(self):
weixin=self.htmlForSoup.select('.social-icon-weixin')
if len(weixin):
return True
return False
def saveGirl(self):
print("嗯,存下来")
girl={}
# 检查是否有微信
if self.checkIfHasWeixin():
girl['weixin']=1
else:
girl['weixin']=0
girl['url']=self.url
db=self.conn.jianshu
db.girls.insert(girl)
def getOtherPeople(self):
# user_list=self.htmlForSoup.find('ul',class_="user-list")
# if user_list:
# for user in user_list.children:
# if isinstance(user,element.Tag):
# a=user.a
# print(a['href'])
people=[]
user_list=BeautifulSoup(requests.get(self.url+"?_pjax=%23list-container").text,"html.parser")
a_array=user_list.find_all('a',class_="avatar")
for a in a_array:
idprel=re.compile(r'/u/(.*)')
ids=idprel.findall(a['href'])
if len(ids):
people.append(ids[0])
return people
def start(self):
self.request()
if self.checkIfFemale():
#发现是个女孩子,开始存储她的信息
self.saveGirl()
#返回这个女孩关注的其他女孩子
return self.getOtherPeople()
return []
网友评论