Skip to content

Commit 03a8bf6

Browse files
author
lmc
committed
Merge branch 'test'
2 parents d4139b3 + c44a777 commit 03a8bf6

File tree

6 files changed

+209
-84
lines changed

6 files changed

+209
-84
lines changed

.idea/workspace.xml

Lines changed: 105 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ python案例分享
55
案例二:python unittest使用<br>
66
案例三:python selenium使用<br>
77
案例四:unittest_selenium使用<br>
8+
案例五:python selenium递归<br>
9+
10+
811

geckodriver.log

Whitespace-only changes.

readFile.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from time import sleep
2+
from selenium import webdriver
3+
4+
def getFile(url):
5+
#实例化一个浏览器驱动
6+
chrome = webdriver.Chrome()
7+
8+
#访问页面
9+
chrome.get(url)
10+
#捕获元素
11+
12+
texts = chrome.find_elements_by_xpath("//div[@class='content']/p")
13+
for t in texts:
14+
print(t.text)
15+
sleep(1)
16+
next_url = chrome.find_elements_by_xpath("//a[@class='nextchapter']")
17+
if next_url:
18+
next_urls = next_url[0].get_attribute("href")
19+
getFile(next_urls)
20+
else:
21+
chrome.close()
22+
return
23+
#关闭浏览器

report.html

Whitespace-only changes.

0 commit comments

Comments
 (0)