Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copy & Paste Web Page
#1
Is there a way to copy all text on a webpage and paste in a variable in Python 3.62 ?

I am looking for a solution that does not use SendKeys("^a",0)/SendKeys("^c",0)
Reply
#2
If you mean just the html of the page then page is the variable that contains the webpage HTML

import urllib.request
f = urllib.request.urlopen(URL)
page = f.read()
import requests
r = requests.read(URL)
page = r.text
Recommended Tutorials:
Reply
#3
Sorry, I may not make clear. I only need all text on webpage, not all html. For example, If I

1. Launch https://www.google.com
2. Press Ctrl+a -- select All
3. Press Ctrl+c -- copy the selection
4. Press Ctrl+v -- paste to get text as below
but I don't want to use SendKeys


About Store
Gmail
Images




Switch to Chrome
Hide annoying ads and protect against malware on the web
NO THANKSYES












Ho ho ho! Follow Santa's journey around the world with Google Maps
Google offered in: Français

Canada
PrivacyTermsSettings
AdvertisingBusiness
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  use Xpath in Python :: libxml2 for a page-to-page skip-setting apollo 2 3,629 Mar-19-2020, 06:13 PM
Last Post: apollo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020