Last active
November 12, 2022 16:51
-
-
Save shamilbi/16dcc47812c64882f024c40d3205276a to your computer and use it in GitHub Desktop.
selenium: get page source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.proxy import Proxy, ProxyType | |
URL = "https://www.ozon.ru/category/telefony-i-smart-chasy-15501/?sorting=rating" | |
# proxy list: https://freeproxylists.net/ru.html | |
proxy_addr = '93.123.226.23' | |
proxy_port = '81' | |
prox = Proxy() | |
prox.proxy_type = ProxyType.MANUAL | |
prox.http_proxy = f"{proxy_addr}:{proxy_port}" | |
#prox.socks_proxy = "ip_addr:port" | |
#prox.ssl_proxy = f"{proxy_addr}:{proxy_port}" | |
capabilities = webdriver.DesiredCapabilities.FIREFOX | |
prox.add_to_capabilities(capabilities) | |
with webdriver.Firefox(desired_capabilities=capabilities) as driver: | |
#driver.maximize_window() | |
driver.get(URL) | |
pageSource = driver.page_source | |
with open("page_source.html", "w", encoding='utf-8') as fileToWrite: | |
fileToWrite.write(pageSource) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment