convert image relative url to absolute url

This commit is contained in:
lededev
2021-06-11 13:53:08 +08:00
parent 8fbe101196
commit 3cce315100
3 changed files with 14 additions and 14 deletions

View File

@@ -17,7 +17,8 @@ def getActorPhoto(htmlcode): #//*[@id="star_qdt"]/li/a/img
l=i.a['href']
t=i.get_text()
html = etree.fromstring(get_html(l), etree.HTMLParser())
p=str(html.xpath('//*[@id="waterfall"]/div[1]/div/div[1]/img/@src')).strip(" ['']")
p=abs_url("https://www.javbus.com",
str(html.xpath('//*[@id="waterfall"]/div[1]/div/div[1]/img/@src')).strip(" ['']"))
p2={t:p}
d.update(p2)
return d
@@ -47,12 +48,7 @@ def getYear(htmlcode): #获取年份
def getCover(htmlcode): #获取封面链接
doc = pq(htmlcode)
image = doc('a.bigImage')
uri = image.attr('href')
if uri.startswith('http'):
return uri
if uri[0] != '/':
uri = '/' + uri
return "https://www.javbus.com" + uri
return abs_url("https://www.javbus.com", image.attr('href'))
def getRelease(htmlcode): #获取出版日期
html = etree.fromstring(htmlcode, etree.HTMLParser())
result = str(html.xpath('/html/body/div[5]/div[1]/div[2]/p[2]/text()')).strip(" ['']")