当前位置:网站首页>Playwright contrôle l'ouverture de la navigation Google locale et télécharge des fichiers
Playwright contrôle l'ouverture de la navigation Google locale et télécharge des fichiers
2022-04-23 13:12:00 【Deux tartes à la citrouille.】
Contrôlez Google explorer pour l'ouvrir et je vais directement àCode source de Big BossC'est,J'ai surtout parlé de téléchargement.
from getpass import getuser
import time
from playwright.sync_api import sync_playwright
import requests
# Pas d'accident, ça peut t'avoir.googleFichier cache local pour
__USER_DATE_DIR_PATH__ = f"C:\\Users\\{getuser()}\\AppData\Local\Google\Chrome\\User Data"
# chrome.exe Adresse
__EXECUTABLE_PATH__ = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
playwright = sync_playwright().start()
browser = playwright.chromium.launch_persistent_context(
# Spécifiez l'adresse du cache utilisateur natif
user_data_dir=__USER_DATE_DIR_PATH__,
# Spécifier natifgoogleClientexeChemin vers
executable_path=__EXECUTABLE_PATH__,
# Pour télécharger des fichiers à partir de ce fichier, il faut ouvrir Par défautFalse
accept_downloads=True,
# Le réglage n'est pas sans tête
headless=False,
bypass_csp=True,
slow_mo=10,
#Sauter la détection
args=['--disable-blink-features=AutomationControlled']
)
page = browser.new_page()
'''Télécharger'''
# Ouvrez le téléchargeur
with page.expect_download() as download_info:
#Trouvez ce que vous voulez télécharger,Trouver l'élément cliqué,Cliquez sur
downloadx = '//*[@id="_view_1545184311000"]/div[2]/div[4]/a[3]'
page.click(downloadx)
# Télécharger quelque chose
download = download_info.value
# Chemin de téléchargement
print(download.path())
# Nom du fichier téléchargé
print(download.suggested_filename)
Quelques questions de téléchargement
Première explication download Il y a trois méthodes appelables ,Respectivement.
download.path()
download.save_as()
download.suggested_filename
13 est le nom et le chemin du fichier , Le second peut définir le chemin de stockage , Mais cette méthode n'est disponible qu'après le téléchargement ,Et oui.D,E Le disque n'a pas accès , Ça ne sert à rien de dire .C'est pour ça qu'il faut le savoir.playwright Paramètres de stockage par défaut pour.
Par défaut,Chaque utilisationwith as Ouvrez le téléchargement et C:\Users\ADMINI~1\AppData\Local\Temp\Créer un sous le chemin Par playwright-artifacts-cLLZs3 Dossier nommé,cLLZs3 Est généré au hasard à chaque ouverture . Le nom du fichier téléchargé est également Au hasard GUID.Par exemple 3c5b244f-4a05-44d7-bb03-0e9fc863abe2 20220422162554220422BPA2ZFNR40.zip
版权声明
本文为[Deux tartes à la citrouille.]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231312102892.html
边栏推荐
- 4.22 study record (you only did water problems in one day, didn't you)
- 【动态规划】221. 最大正方形
- Complete project data of UAV apriltag dynamic tracking landing based on openmv (LabVIEW + openmv + apriltag + punctual atom four axes)
- 5 tricky activity life cycle interview questions. After learning, go and hang the interviewer!
- EMMC / SD learning notes
- Common interview questions and detailed analysis of the latest Android developers in 2020
- Ffmpeg common commands
- Melt reshape decast long data short data length conversion data cleaning row column conversion
- R语言中dcast 和 melt的使用 简单易懂
- 数据仓库—什么是OLAP
猜你喜欢
榜样专访 | 孙光浩:高校俱乐部伴我成长并创业
100 GIS practical application cases (53) - making three-dimensional image map as the base map of urban spatial pattern analysis
2020年最新字节跳动Android开发者常见面试题及详细解析
X509 parsing
nodeJs + websocket 循环小案例
MySQL -- 16. Data structure of index
叮~ 你的奖学金已到账!C认证企业奖学金名单出炉
内核错误: No rule to make target ‘debian/canonical-certs.pem‘, needed by ‘certs/x509_certificate_list‘
AUTOSAR from introduction to mastery 100 lectures (86) - 2F of UDS service foundation
Common interview questions and detailed analysis of the latest Android developers in 2020
随机推荐
The project file '' has been renamed or is no longer in the solution, and the source control provider associated with the solution could not be found - two engineering problems
解决Oracle中文乱码的问题
Proteus 8.10 installation problem (personal test is stable and does not flash back!)
Nodejs + websocket cycle small case
Pyqt5 store opencv pictures into the built-in sqllite database and query
数据仓库—什么是OLAP
AUTOSAR from introduction to mastery 100 lectures (86) - 2F of UDS service foundation
5 tricky activity life cycle interview questions. After learning, go and hang the interviewer!
Ffmpeg common commands
Imx6ull QEMU bare metal tutorial 1: GPIO, iomux, I2C
Request和Response及其ServletContext总结
2020最新Android大厂高频面试题解析大全(BAT TMD JD 小米)
Go language mapping operation
How to convert opencv pictures to bytes
Imx6ull QEMU bare metal tutorial 2: usdhc SD card
Uniapp image import local image not displayed
AUTOSAR from introduction to mastery lecture 100 (84) - Summary of UDS time parameters
jmeter操作redis
Read the data in Presto through sparksql and save it to Clickhouse
Connect orcale