Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.6k views
in Technique[技术] by (71.8m points)

beautifulsoup - Extracting Page Source with Python

Is there a way to extract the whole source page in exactly same way as you would be seeing it when you click rmb 'View page source' on a browser, just a raw page with thousands of lines of text?. I've tried requests.get(), but I'm only getting a fraction of it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
from selenium import webdriver

browser = webdriver.Chrome()
browser.get('https://whateverpage.com')
x = browser.page_source

print(x)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...