惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
T
The Blog of Author Tim Ferriss
Microsoft Azure Blog
Microsoft Azure Blog
U
Unit 42
IT之家
IT之家
D
DataBreaches.Net
Y
Y Combinator Blog
B
Blog RSS Feed
F
Fortinet All Blogs
GbyAI
GbyAI
V
Visual Studio Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
美团技术团队
L
LangChain Blog
N
Netflix TechBlog - Medium
G
Google Developers Blog
Recent Announcements
Recent Announcements
T
Tailwind CSS Blog

qubeijun的博客

言语理解与表达 父亲往事-我儿子叫冬冬 公务员行测答题顺序及用时及答题技巧 判断推理 数量关系 冬甜夫妇5-10-5-21日本蜜月行程安排回归总结篇(无图片) 冬甜夫妇5.10-5.21日本蜜月行程安排计划篇 5.1 小贝壳疫苗计划 100DAYS 父亲往事-猴牤大爷的“帽子” 父亲往事-姨妈家的葡萄架 父亲往事-十五的月饼 父亲往事-姑妈的压岁钱 父亲往事-母亲的缝纫机父亲的锯 父亲往事-家属来队 父亲往事-新兵连的生活 父亲往事-村北的槐树林 父亲往事-小贝壳 公务员面试 系统架构设计师 图形推理 数学运算 父亲往事-惊蛰 资料分析 父亲往事-偷吃西红柿有绝窍 父亲往事-毯子衣服 父亲往事-水壶煮鸡蛋 父亲往事-煎饼蘸香油 系统架构设计师论文
python+selenium搜狗微信主页抓取
qubeijun · 2017-10-24 · via qubeijun的博客

发表于|更新于|python

|总字数:189|阅读时长:1分钟|浏览量:|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# coding:utf-8

from selenium import webdriver
from selenium.webdriver.common.action_chains import *
import time

url = 'http://weixin.sogou.com/'

for i in range(0, 22):
browser = webdriver.PhantomJS()
browser.get(url)
browser.refresh()

# 鼠标悬停‘更多’
implement = browser.find_element_by_xpath("//a[@id='more_anchor']")
ActionChains(browser).move_to_element(implement).perform()
time.sleep(2)

# 点击标签
browser.find_element_by_xpath("//a[@id='pc_"+str(i)+"']").click()
x = browser.find_element_by_xpath("//a[@id='pc_"+str(i)+"']")
# print x.text

# 点击‘加载更多内容’
browser.find_element_by_xpath("//a[@id='look-more']").click()
time.sleep(2)
browser.find_element_by_xpath("//a[@id='look-more']").click()
time.sleep(2)
for j in range(0, 40):
title = browser.find_element_by_xpath("//a[@uigs='pc_"+str(i)+"_"+str(j)+"_title']")
detail = browser.find_element_by_xpath("//a[@uigs='pc_"+str(i)+"_"+str(j)+"_title']/../..//p")
s = x.text+' '+title.text+' '+detail.text
print s

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 qubeijun的博客

赞助

  • 微信

    微信

  • 支付宝

    支付宝