· 4 years ago · Sep 01, 2021, 04:36 AM
1
2Bad API request, Api Paste Key is invalid.
3
4def xyzcomics(search):
5 #This is more a template than an actual function, so you know change things up.
6 web=requests.get("https://xyzcomics.com/?s=__searched__",headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15'})
7 soup = BeautifulSoup(web.text,"html.parser")
8 pages = 1
9 if not "__PAGEELEMENT"=="":
10 for page in soup.select("1"):
11 if page.text.isnumeric() and int(page.text)>pages:
12 pages = int(page.text)
13 elif page.text.find("of ")>-1 and page.text.split("of ")[1].isnumeric() and int(page.text.split("of ")[1])>pages:
14 pages = int(page.text.split("of ")[1])
15 else:
16 pages=""
17 if pages==1:
18 pages = str(pages)
19 else:
20 pages = str(random.randint(1,pages))
21 if type(pages)==int:
22 web = requests.get(__blank__,headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Safari/605.1.15','Referer':"https://xyzcomics.com/?s=__searched__"})
23 else:
24 web = web
25 soup = BeautifulSoup(web.text,"html.parser")
26 links = []
27 for elm in soup.select("div.entry-featured-media"):
28 try:
29 if "https://"+"https://xyzcomics.com".split("/")[2] in elm.findChildren("a")[0]["href"]:
30 links.append(elm.findChildren("a")[0]["href"])
31 else:
32 links.append("https://"+"https://xyzcomics.com".split("/")[2]+elm.findChildren("a")[0]["href"])
33 except Exception:
34 pass
35 numb = len(links)
36 if numb<=1:
37 numb=0
38 else:
39 numb = random.randint(0,len(links)-1)
40 web = requests.get(links[numb])
41 soup = BeautifulSoup(web.text,"html.parser")
42 imgs = []
43 for img in soup.find_all("img"):
44 if "https://xyzcomics.com/wp-content/uploads/" in img["src"] and not "logo" in img["src"]:
45 imgs.append(img["src"])
46 return imgs
47