Answers for "python download web page"

1

how to download a page in python

import urllib.request, urllib.error, urllib.parse
url = "The url of the page you want to download"
response = urllib.request.urlopen(url)
Posted by: Guest on July-16-2020
0

python download complete web page

# pip install selenium
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

br = webdriver.Firefox(firefox_binary=binary,
                               executable_path="path_to_webdriver")

br.get('http://www.google.com/')

save_me = ActionChains(br).key_down(Keys.CONTROL)
         .key_down('s').key_up(Keys.CONTROL).key_up('s')
save_me.perform()
Posted by: Guest on May-23-2021
0

python download html as string

# open-webpage.py

import urllib.request, urllib.error, urllib.parse

url = 'http://www.oldbaileyonline.org/browse.jsp?id=t17800628-33&div=t17800628-33'

response = urllib.request.urlopen(url)
webContent = response.read()

print(webContent[0:300])
Posted by: Guest on December-03-2020

Browse Popular Code Answers by Language