Add {scanlibs,bookys}.py

This commit is contained in:
Benjamin Loison 2023-05-01 23:15:23 +02:00
commit 1a7d5b424a
Signed by: Benjamin_Loison
SSH Key Fingerprint: SHA256:BtnEgYTlHdOg1u+RmYcDE0mnfz1rhv5dSbQ2gyxW8B8
2 changed files with 70 additions and 0 deletions

25
bookys.py Normal file
View File

@ -0,0 +1,25 @@
import requests
def getContentFromURL(url):
return requests.get(url).text
c = 0
for i in range(36, 203):#1, 203):
print(i)
url = f'https://ww9.bookys-ebooks.com/sitemaps/items{i}.xml'
sitemapContent = getContentFromURL(url)
jsonData = xmltodict.parse(sitemapContent)['urlset']['url'][1:]
for entry in jsonData:
#print(entry)
loc = entry['loc']
if loc.startswith('https://ww9.bookys-ebooks.com/livres/'):
#print(entry)
print(i, c)
print(loc)
content = getContentFromURL(loc)
title = content.split('<title>')[1].split('\n')[0]
print(title)
print()
c += 1

45
scanlibs.py Normal file
View File

@ -0,0 +1,45 @@
import requests, re
from lxml import html
from xml.etree.ElementTree import XML, fromstring
def getContentFromURL(url):
return requests.get(url).text
sitemapUrl = 'https://scanlibs.com/sitemap.xml'
sitemapContent = getContentFromURL(sitemapUrl)
"""
sitemapXML = fromstring(sitemapContent)
for elem in sitemapXML.iter():
for el in elem.iter():
print(el.tag, ':', el.text)
#print('!', elem.text, '!')
import xmltodict, json
"""
jsonData = xmltodict.parse(sitemapContent)['urlset']['url'][1:]
for entry in jsonData:
loc = entry['loc']
print(loc)
print(entry['lastmod'])
print(entry['image:image']['image:loc'])
while True:
content = getContentFromURL(loc)
tree = html.fromstring(content)
title = content.split('<title>')[1].split('</title>')[0]
if not title.startswith('503 Service Temporarily Unavailable'):
break
else:
print('MISS')
print(title)
print()
continue
metaPattern = 'border-bottom:1px solid #f0f0f0">'
meta = content.split(metaPattern)[1].split('</p>')[0]
print(meta)
description = content.split('"></span>')[1].split('<a class="rewlink"')[0]
print(description)
print()