Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javdb的封面元素改变导致无法削刮成功~更改元素名称 #17

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
javdb的封面元素改变导致无法削刮成功~更改元素名称
更改后即可削刮成功
  • Loading branch information
pikachullk authored Jul 22, 2020
commit 74cc413e0f63a28acfc59443f3d5a5865d8b3edc
4 changes: 2 additions & 2 deletions Getter/javdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ def getCover_small(htmlcode, count):

def getCover(htmlcode):
html = etree.fromstring(htmlcode, etree.HTMLParser())
result = str(html.xpath("//img[@class='box video-cover']/@src")).strip(" ['']")
result = str(html.xpath("//img[@class='video-cover']/@src")).strip(" ['']")
# 有时xpath找不到元素,所以要用bs4
if not result:
soup = BeautifulSoup(htmlcode, 'lxml', parse_only=SoupStrainer('img', {'class': 'box video-cover'}))
soup = BeautifulSoup(htmlcode, 'lxml', parse_only=SoupStrainer('img', {'class': 'video-cover'}))
if soup.img is not None:
result = soup.img['src']
return result
Expand Down