When I pip install pickle I am facing this error error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools":
When I pip install pickle I am facing this error error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools":
我正在尝试绘制来自 Facebook 的 cookie。我的意图是使用 selenium 进行 Web 自动化。我在用 pickle 抓饼干。
代码:
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/
基于那个错误:
"C:\Users\User\PycharmProjects\Campaign\Experiments\Cookies.py", line 47 cookies_location = "C:\Users\User\PycharmProjects\Campaign\Experiments\cookies.txt" ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
您遇到了 Unicode 问题。
cookies_location = r"C:\Users\User\PycharmProjects\Campaign\Experiments\cookies.txt
在你的字符串前加上 r 解决你的问题。
免责声明:我从 OP 问题中提取了这个答案。 Answers should not be contained in the question itself.
答案由Jony Ghosh提供:
您不必安装 pickle 。 Pickle 已经在 python 标准库中。当我从事这项工作时,我了解到了这一点。
感谢 @tdelaney 让我知道它是 python 标准库的一部分。
我正在尝试绘制来自 Facebook 的 cookie。我的意图是使用 selenium 进行 Web 自动化。我在用 pickle 抓饼干。
代码:
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/
基于那个错误:
"C:\Users\User\PycharmProjects\Campaign\Experiments\Cookies.py", line 47 cookies_location = "C:\Users\User\PycharmProjects\Campaign\Experiments\cookies.txt" ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
您遇到了 Unicode 问题。
cookies_location = r"C:\Users\User\PycharmProjects\Campaign\Experiments\cookies.txt
在你的字符串前加上 r 解决你的问题。
免责声明:我从 OP 问题中提取了这个答案。 Answers should not be contained in the question itself.
答案由Jony Ghosh提供:
您不必安装 pickle 。 Pickle 已经在 python 标准库中。当我从事这项工作时,我了解到了这一点。 感谢 @tdelaney 让我知道它是 python 标准库的一部分。