【測試技術打卡】第1天:pip切源,Python+selenium

2020.05.25
這篇博文的初衷就是要每天提醒自己學一點技術,記錄學了什麼,遇到什麼困難等。

1、換源,將pip源更換到國內鏡像

以下摘錄自CSDN博主「黑影隱」的原創文章,原文鏈接
windows下,直接在user目錄中創建一個pip目錄,如:C:\Users\xx\pip,然後新建文件pip.ini,即 %HOMEPATH%\pip\pip.ini,在pip.ini文件中輸入以下內容(以豆瓣鏡像爲例):

[global]
index-url = http://pypi.douban.com/simple
[install]
trusted-host = pypi.douban.com

比較常用的國內鏡像包括:

(1)阿里雲 http://mirrors.aliyun.com/pypi/simple/
(2)豆瓣http://pypi.douban.com/simple/
(3)清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/
(4)中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/
(5)華中科技大學http://pypi.hustunique.com/

2、Python+selenium

下載selenium

pip install selenium

下載chromedriver

1、http://chromedriver.storage.googleapis.com/index.html
2、https://npm.taobao.org/mirrors/chromedriver/

這裏chrome版本和chromedriver版本一定要匹配

chrome版本查看->幫助->關於google chrome,然後我的版本是86的,鏈接1下了之後版本老是提示不對,換了鏈接2才能用

然後將chromedriver放在chrome的安裝目錄下

打開jupyter notebook

from selenium import webdriver
import time

def main():
    chrome_driver = 'C:\xxxxx\Google\Chrome\Application\chromedriver.exe'
    b = webdriver.Chrome(executable_path=chrome_driver)
    b.get("https://www.baidu.com")
    time.sleep(5)
    b.quit()
    
if __name__== '__main__':
    main()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章