Scrapy 不必要的 HTML 输出
Unnecessary HTML output with Scrapy
我正在抓取 h1
标签的 HTML
。 selector
只针对 h1
标签,但是当我打印它时,它还会打印一个不必要的 HTML
和 h1
标签。
import requests
from scrapy.selector import Selector
r = requests.get('https://www.catholicgallery.org/mass-reading/310122/')
resp = Selector(text=r.text)
h1 = resp.xpath('//h1[@class="tdb-title-text"]').get()
print(h1)
输出:
它似乎受此问题影响:
scrapy/parsel: HTML code extraction from node is not working #228
据说降级libxml
到2.9.10可以解决这个问题
我正在抓取 h1
标签的 HTML
。 selector
只针对 h1
标签,但是当我打印它时,它还会打印一个不必要的 HTML
和 h1
标签。
import requests
from scrapy.selector import Selector
r = requests.get('https://www.catholicgallery.org/mass-reading/310122/')
resp = Selector(text=r.text)
h1 = resp.xpath('//h1[@class="tdb-title-text"]').get()
print(h1)
输出:
它似乎受此问题影响:
scrapy/parsel: HTML code extraction from node is not working #228
据说降级libxml
到2.9.10可以解决这个问题