<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr class="bbs_tb3" style="background-color: rgb(243, 243, 243);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
<tr style="background-color: rgb(255, 255, 255);"></tr>
想从这里开始取,前面的10组tr不要,
<tr class="bbs_tb3" style="background-color: rgb(243, 243, 243);"></tr>
不能循环 指定从第几行开始,因为不是固定的,只能是从bbs_tb3 class这里入手,
求大佬给个思路
重庆网友:目测是小说站 可视化采集
宁夏网友:你从bbs开始匹配不是就可以了吗
甘肃网友:
我要这个tbody里面的 所有内容呀,
就不要前面10条tr 就是不知道怎么才能取,
循环是要循环的,但是循环后不能指定从第11条开始取
php er
新疆网友:如果确定只是重复相同的tr内容,直接替换就行,简单直接
内蒙古网友:
不能替换呀,tr里面还有td 里面内容就不能替换
所以 循环后 取 后面的 第11条下标 开始 不知道 怎么取 ,这个11不是确定 固定的
江西网友:取完,然后删掉前面10行不就行了
陕西网友:
这个10行不是固定的呀,
这10行是置顶的帖子, 万一不置顶了,那就没有10行了,
根本不知道要删除几行
广东网友:不能循环?
- import re
- from lxml import etree
- s = ”'<tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr class="bbs_tb3" style="background-color: rgb(243, 243, 243);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>
- <tr style="background-color: rgb(255, 255, 255);"></tr>”’
- html = etree.HTML(s)
- node = html.xpath(‘//tr[@class="bbs_tb3"]/following::tr’)
- print(len(node))
复制代码
上海网友:去了解一下QueryList
优雅的渐进式PHP采集框架,让采集更简单一点。
广东网友:去了解一下QueryList
优雅的渐进式PHP采集框架,让采集更简单一点。
山东网友: python 不会啊,能转成php吗
甘肃网友:这个跟python php 没太大关系 主要是xpath语法
甘肃网友:取完用bbs关键字分割一下呗
广西网友:而且从没有用php做过爬虫, 所以你要php代码就爱莫能助了
总体思路都差不多
看你要怎么解决
原始点用正则就前视
用xpath或者bs解析网页 就找相应的语法看看
江西网友:。。。。。他是phper,不是pyer,py简单的一逼
天津网友:跟语言关系不大, php总有正则吧, 前视断言就行
青海网友:xpath
湖南网友:玩爬虫不会连html解析框架都不知道吧,还是根本就欠缺编程思维,别只背几个语法和几个API。
最简单,找个php的html解析框架,直接循环tr,声明一个标记变量,判断`bbs_tb3`后标记变量为true。
天津网友:index = s.index(‘bbs_tb3’)
content = s[index-11:]
甘肃网友:index = s.index(‘bbs_tb3’)
content = s[index-11:]
湖北网友:怎么样,是一个类库 还是啥, github 更新是10个月前的
云南网友:google `php html parser`,比如 https://github.com/paquettg/php-html-parser
未经允许不得转载:美国VPS_搬瓦工CN2 GIA VPS » 爬虫大佬在吗