- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已经创建了一个连接到 LinkedIn 页面的链接列表。这些链接是使用 LinkedIn 的招聘人员功能(在付费专区后面)聚合的。当我将链接粘贴到我的浏览器并检查 html 代码时,它看起来很标准并且我能够轻松地识别我正在搜索的元素(见下文)。
但是,当我运行我的 python 代码并使用漂亮的汤来获取 HTML 时,返回的 HTML 与浏览器的检查元素 View 中的外观完全不同。 HTML 不是普通的标签,而是充满了变量,基本上看起来像我以前从未见过的东西(没有做过大量的抓取)。
是否有可能获得看起来像我在浏览器上看到的那样的 HTML,而不是这种看起来很疯狂的东西?这些链接是使用 recuriter 搜索功能编译的,所以我想我以某种方式使用搜索变量而不是实际结果来提取 html,但我真的不知道。
这是我用来创建 html 文件的代码。我希望最后一行提取我正在寻找的数据,假设我可以获得正确的 html。
#Used to create file
with open('departures.csv', mode='r') as csv_file:
csv_reader = csv.DictReader(csv_file)
for row in csv_reader:
browser.get(row['link'])
page = BeautifulSoup(browser.page_source, 'lxml')
html = page.prettify()
with open("output1.html", "w") as file:
file.write(unicode(html))
#Code I want to Run right now it just returns an empty list
position = page.find_all('span', class_= 'keyword')
当我使用浏览器转到链接时,我试图找到显示的 HTML:
<span class="keyword"> Account Manager</span>
Small Piece of Actual HTML returned: <code id="profile-data" style="display: none;">
<!--{"breadcrumbs":{"customSearchURL":"/recruiter/smartsearch? updateSearchHistory=false&decorateHits=true&decorateFacets=false&doFacetCounting=true&searchHistoryId=3392867616&resetFacets=false&searchCacheKey=f4b1a865-50e8-4f59-ba48-9dff595e63e5%2CoUbi&searchRequestId=4d25da0f-1f73-4722-8586-9652b3f98b97%2CQSZO&doResultCaching=false&forceResultFromCache=false&origin=PPSL&doProjectBasedCounting=false&count=25&start=700","linkContext":"Controller:smartSearch,Action:search,ID:3392867616","context":
最佳答案
LinkedIn 使用大量 JavaScript 来生成您在浏览器中看到的页面。开发人员工具中的 DOM 元素检查器向您显示该 JS 执行的当前结果,而不是浏览器下载的原始 HTML 页面。
要在浏览器中查看实际的 HTML 页面源代码,请使用查看源代码(Ctrl+U 或 Command+U)。这应该显示类似于您在 Python 中获得的 HTML。
如果您需要对最终生成的 DOM 输出进行一些抓取,您可能需要使用 headless browser可以执行 JavaScript,例如 Chrome controlled by Puppeteer .
关于python - BeautifulSoup 返回充满变量的 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57341556/
我有一个 Storm 拓扑,其中一个 bolt 应该与ElasticSearch交互。 public static Client client; public static Settings sett
我目前正在开发 LIMS。我需要检索与需要使用某种准备方法准备的实验室 sample 相关的信息。 (我对此进行了相当多的简化,因此对任何错误表示歉意。)我需要在查询结果中生成的列是: Sample
我必须以下文件夹结构: main - server -- server-module-1 --- a --- b --- c -- server-module-2 --- d --- e --- f
Tomcat 和我的自定义 JAAS LoginModule 运行良好,但每次我输入错误的凭据时,整个 LoginException 都会写入日志。根据定义,LoginModule 必须在身份验证失败
我一直在关注有关 iOS 开发的教程 - 特别是向下钻取 UITableViews。我建立了自己的自定义 plist,但我似乎无法让 DetailViewController 填充我的 plist 信
我对 QT 比较陌生。在我的代码中,我创建了一个 QTableWidget,遍历行并将单元格设置为 QLineEdits 和 QCheckBoxes。我想这样做,以便更改任何 QLineEdits 中
我刚开始使用 Chrome 的分析器。所以这可能是对我得到的结果的误解。 如果我打开 Chrome 分析器并拍摄以下网页的堆快照,我会注意到 obj3 的保留大小是 obj1 和 obj2 的保留大小
我正在尝试使用 Python 2.7 中的 BeautifulSoup 4 解析 youtube 评论。当我尝试播放任何 YouTube 视频时,我会收到充满 BOM 的文本,而不仅仅是在文件开头:
我有此消息的完整系统日志: mysqld[963]: 2016-10-23 20:54:14 140708269390592 [警告] 拒绝用户 ''@'localhost' 访问(使用密码:NO)
我有一个数组,里面装满了NSDictionaries。我想找到其中一本字典的 index,但我对这本字典的了解只是键 @"name"的 value。我该怎么做 ? 最佳答案 在 theArray 中查
我想在之前的div内容满了文字的时候显示div,然后继续用剩下的文字填充这个新的div。 我不知道怎么办。事实上,在下面的代码中我写道,div 是在单击按钮时显示的。我也无法设置上面解释的“填充操作”
这是发生了什么: 内部数据库内容:一个类有一个字符串属性,用于存储电话号码。这个数字是使用代码设置的 CFBridgingRelease(ABMultiValueCopyValueAtIndex(AB
我的 logcat 中收到了数千条以下警告消息,它挤掉了我实际要查找的消息: W/ActivityManager﹕ Wtf, activity ActivityRecord{4338cd90 u0 u
我尝试使用 mongoimport 在 mongodb 中导入单个 csv 文件,使用 mongoimport -d mydb -c things --type csv --file location
我的 Rails 开发日志中有大量这样的行: Started GET "/assets/services.css?body=1" for 127.0.0.1 at 2012-11-26 02:27:4
我在 Xcode 8/iOS 10/Swift 3 中遇到 Firebase 问题。试图让 Firebase Analytics 全部设置好。但是在 iOS10 中,控制台会记录来自 Firebase
我的 logcat 中充满了以下消息 - E/UsDebuggingManager( 476): java.io.IOException: Connection refused E/UsDebugg
总结 我有各种单节点 Kubernetes 集群,这些集群在累积约 300 个已完成的作业后变得不稳定。 例如,在一个集群中,有 303 个已完成的作业: root@xxxx:/home/xxxx#
我是一名优秀的程序员,十分优秀!