当前位置:网站首页>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
边栏推荐
- Community version Alibaba MQ ordinary message sending subscription demo
- three.js文字模糊问题
- @优秀的你!CSDN高校俱乐部主席招募!
- Subscribe to Alibaba demo send business messages
- Proteus 8.10 installation problem (personal test is stable and does not flash back!)
- The difference between string and character array in C language
- Complete project data of UAV apriltag dynamic tracking landing based on openmv (LabVIEW + openmv + apriltag + punctual atom four axes)
- Design of STM32 multi-channel temperature measurement wireless transmission alarm system (industrial timing temperature measurement / engine room temperature timing detection, etc.)
- Common interview questions and detailed analysis of the latest Android developers in 2020
- Nodejs + Mysql realize simple registration function (small demo)
猜你喜欢
榜样专访 | 孙光浩:高校俱乐部伴我成长并创业
three. JS text ambiguity problem
X509 parsing
Design of STM32 multi-channel temperature measurement wireless transmission alarm system (industrial timing temperature measurement / engine room temperature timing detection, etc.)
2020最新Android大厂高频面试题解析大全(BAT TMD JD 小米)
【动态规划】221. 最大正方形
Servlet of three web components
51 single chip microcomputer stepping motor control system based on LabVIEW upper computer (upper computer code + lower computer source code + ad schematic + 51 complete development environment)
【快排】215. 数组中的第K个最大元素
R语言中dcast 和 melt的使用 简单易懂
随机推荐
解决虚拟机中Oracle每次要设置ip的问题
Design and manufacture of 51 single chip microcomputer solar charging treasure with low voltage alarm (complete code data)
AUTOSAR from introduction to mastery 100 lectures (50) - AUTOSAR memory management series - ECU abstraction layer and MCAL layer
Utils of various date conversion
7_Addmodule和基因加和法add 得到的细胞类型打分在空间上空转对比
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
[walking notes]
AUTOSAR from introduction to mastery 100 lectures (86) - 2F of UDS service foundation
Translation of attention in natural language processing
Kernel error: no rule to make target 'Debian / canonical certs pem‘, needed by ‘certs/x509_ certificate_ list‘
mui + hbuilder + h5api模拟弹出支付样式
Analysis of the latest Android high frequency interview questions in 2020 (BAT TMD JD Xiaomi)
100 GIS practical application cases (52) - how to keep the number of rows and columns consistent and aligned when cutting grids with grids in ArcGIS?
Vscode tips
Common interview questions and detailed analysis of the latest Android developers in 2020
Loading and using image classification dataset fashion MNIST in pytorch
Conflict between Mui picker and drop-down refresh
decast id.var measure.var数据拆分与合并
ESP32 VHCI架构传统蓝牙设置scan mode,让设备能被搜索到
5道刁钻的Activity生命周期面试题,学完去吊打面试官!