爬蟲框架scrapy
1 #mac 安裝scrapy 2 pip install scrapy
1 python 使用MySQL模塊出現 ModuleNotFoundError: No module named 'mysql' 2 解決方法 pip install mysql-connector 3 4 python使用mysql出現 mysql.connector.errors.NotSupportedError: Authentication plugin 'caching_sha2_password' is not supported 5 解決方法 pip install mysql-connector-python
1 mac 安裝軟件。磁盤已壞,推出磁盤,應用不安全。 2 解決方法 sudo spctl --master-disable
python 爬蟲知識
1 resp = requests.get(url) 2 #resp.text 和resp.content打印出的內容不同。前者經過自動解碼,后者只是一個字節流。為什么? 3 #resp.text自動解碼的過程。 4 #requests/adapt.py文件中的build_response方法返回服務器內容的解碼方式。 5 #build_response方法中get_encoding_from_header方法位于requests/utils.py文件中。具體解析出服務器內容的編碼方式。返回build_response到response.encoding。 6 #服務器沒有說明編碼的方式,則到requests/modules.py文件中有apparent_ecoding方法,里面有chardet。這是在服務器返回內容中查找是否有特殊碼,于是解析出具體編碼方式。
1 resp有text,content,cookies,headers,history
1 mysql_connector.MySQLInterfaceError: Python type list cannot be converted 2 Python連接mysql時,由于寫入到MySQL中的一個時間變量類型設置不匹配引發的錯誤。將DATE轉為DATETIME即可執行。
1 官網下載后的python程序在 /usr/local/cellar/python下。包括官網提供的IDE,python launch等。這其實就是類似于tomcat,nginx這些服務器的一種應用程序,里面有二進制可執行文件,有庫函數等。 2 3 有了Python程序后,還不能直接運行使用Python編寫的用戶程序。需要框架的作用。鏈接一些庫函數才能真正執行。 4 下載的框架路徑 /usr/local/Frameworks/python.framework 5 6 編寫一些Python程序,需要用到一些第三方的Python庫。安裝到MAC的位置 7 /usr/local/bin,/usr/local/lib/python3.7/site-packages

浙公網安備 33010602011771號