我在编写代码时遇到麻烦,该代码应该从网站上读取内容。 我找到了一个站点(https://docs.python-guide.org/scenarios/scrape/),该站点可以帮助我理解模块“请求”将是我的理想解决方案,但是我遇到的问题是,我需要将当前活动的浏览器内容纳入此代码{{1} },因为重新加载页面会更改内容。
我正在使用以下代码打开浏览器:
page = requests.get(url)
然后我与网站进行了一些互动,并希望使用它
def ffox_open(url,download_path,profile_id=""):
if profile_id =="":
profile_id = 'bla'
profile = webdriver.FirefoxProfile('/scripts/python/config/firefox/'+profile_id)
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.dir", download_path)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "text/csv,application/vnd.ms-excel, application/force-download, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/msword, application/XLS;text/csv, application/XLSX, application/csv, application/ris, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed, application/download, application/octet-stream")
profile.set_preference("browser.helperApps.alwaysAsk.force", False)
browser = webdriver.Firefox(firefox_profile=profile)
browser.get(url)
return browser
url = 'www.hereismyurl'
browser = ffox_open(url,current_path,ffox_profile)
能请你帮我吗?