Python3代码问题

杰克

我不知道我的问题是什么。这就是终端中出现的内容,我得到一个没有信息的 csv。

$ python3 test1.py

列表 -->

刮痧

回溯(最近一次调用最后一次):

File "test1.py", line 162, in <module>

search_bing(i)

File "test1.py", line 131, in search_bing

driver.get("https://duckduckgo.com/?q=linkedin+" + n + "&t=hb&ia=web")

File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/selenium/webdriver/remote/webdriver.py", line 264, in get

self.execute(Command.GET, {'url': url})

File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/selenium/webdriver/remote/webdriver.py", line 252, in execute

self.error_handler.check_response(response)

File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-
packages/selenium/webdriver/remote/errorhandler.py", line 194, in 
check_response

raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: unknown error: 
Runtime.executionContextCreated has invalid 'context': {"auxData":
{"frameId":"40864.1","isDefault":true},"id":1,"name":"","origin":"://"}

(Session info: chrome=58.0.3029.81)

(Driver info: chromedriver=2.9.248307,platform=Mac OS X 10.12.4 x86_64)

完整脚本如下。您可以忽略输入组代码,因为我正在抓取的网站上的 HTML 会出现在那里,并且这篇文章太长了。

- - 编码:utf-8 - -

from bs4 import BeautifulSoup
from selenium import webdriver
import time
import csv

c = csv.writer(open("linkedin-group-results.csv", "w"))
c.writerow(["Member","Profile"])
driver = webdriver.Chrome(executable_path=r'/usr/local/bin/chromedriver')


your_groups_code = """

#enter group code here
"""

users = []
ul = []
def search_bing(name):
n = name.replace(" ", "+")
driver.get("https://duckduckgo.com/?q=linkedin+" + n + "&t=hb&ia=web")
time.sleep(3)
s = BeautifulSoup(driver.page_source, 'lxml')
fr = s.find("div", class_="result__body links_main links_deep")

for a in fr.find_all('a'):
    try:
        if 'linkedin.com/in' in a['href']:
            print ('found linkedin url'), a['href']
            if a['href'] in ul:
                print ('skipping dup')
            else:
                ul.append(a['href'])
                c.writerow([name, a['href']])
                break
    except Exception as e:
        print (e,'..continue')


soup = BeautifulSoup(your_groups_code, 'lxml')
for a in soup.find_all('img'):
name = a['alt']
if name in users:
    print ('skipping dup')
else:
    users.append(name)

if len(users) > 1:
print ('LIST -->'), users
for i in users:
    print ("Scraping"), i
    search_bing(i)
else:
print ('Congrats! Your making progress.. Now please insert the code of 
the linkedin group you want to scrape (as seen in tutorial)')
迭戈·阿米卡比尔

您似乎在使用旧版本的 ChromeDriver 2.9 ,该版本很可能与 Chrome 58 不兼容。请下载并尝试最新版本 2.29 。请参阅注释:https : //chromedriver.storage.googleapis.com/2.29/notes.txt

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

从PHP运行Python3代码

来自分类Dev

从PHP运行Python3代码

来自分类Dev

如何解决ANTLR 4.4中生成python3代码的错误?

来自分类Dev

暂停Python3代码,直到excel宏完成

来自分类Dev

使用CryptoJS将等效的Python3代码转换为JS DES加密

来自分类Dev

使用解释器在终端中编译python3代码

来自分类Dev

在python3中查找字符的UTF-16代码

来自分类Dev

在python 3中应用python 2代码时遇到问题

来自分类Dev

如何从此python 3代码获取最大的文件?

来自分类Dev

有问题的AS3代码/导出的SWF无法正常工作

来自分类Dev

Visual Studio 2015更新3代码覆盖率问题

来自分类Dev

加快Python 3.4代码的速度

来自分类Dev

将python 2代码移植到python 3:ICMP扫描时出现错误

来自分类Dev

PyCharm:在Python 2项目中打开Python 3代码检查

来自分类Dev

更新后的XCode 6.3代码签名问题

来自分类Dev

我的euler 7代码有什么问题?

来自分类Dev

SHA-2代码签名问题

来自分类Dev

Xcode 7代码签名资源规则路径问题

来自分类Dev

AS3代码结构-使用基本代码

来自分类Dev

AS3代码结构-使用基本代码

来自分类Dev

p.stdout.read()在我的Python 3代码中不起作用

来自分类Dev

哪些2to3修复程序输出有效的Python 2代码?

来自分类Dev

Python ldap3代码从SID获取用户名

来自分类Dev

使用python 3代码在CSV文件中查找特定的标头

来自分类Dev

如何在Visual Studio Code中调试Python 3代码?

来自分类Dev

如何用Python 3代码重写我的附加行?

来自分类Dev

Python 3代码读取CSV文件,进行操作,然后创建新文件。

来自分类Dev

从C#表单应用程序执行python 3代码

来自分类Dev

Python 3代码未按预期执行,给出了错误的数字

Related 相关文章

热门标签

归档