【发布时间】:2021-08-21 05:32:18
【问题描述】:
我正在尝试从 Facebook 绘制 cookie。我的意图是使用 selenium 进行网络自动化。我正在用泡菜来抓饼干。
代码:
import pickle
from selenium import webdriver
driver = webdriver.Chrome("../chromedriver.exe")
def save_cookies(driver, location):
pickle.dump(driver.get_cookies(), open(location, "wb"))
cookies_location = "C:\Users\User\PycharmProjects\Campaign\Experiments\cookies.txt"
# Initial load of the domain that we want to save cookies for
chrome = driver
chrome.get("https://www.facebook.com/")
username = os.environ.get('facebook_zrliqi_email')
password = os.environ.get('facebook_zrliqi_pass')
driver.find_element_by_name("email").send_keys(username)
driver.find_element_by_name("pass").send_keys(password)
driver.find_element_by_name("login").click()
print(input("Press any Key: "))
print("Login work Successfully ")
save_cookies(chrome, cookies_location)
chrome.quit()
但是当我尝试在我的 Pycharm 中安装 pickle 时。我正在获取它需要安装 Visual Studio 工具。
我收到了这个错误:
building 'pickle5._pickle' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
【问题讨论】:
-
你安装了吗 - Microsoft C++ Build Tools
-
不,我没有。让我试试。
-
pickle 是 python 标准库的一部分,不需要安装。
-
@tdelaney 那么为什么我会收到这个错误?