def _fetch(self): response = make_request( self.url, "GET", useragent= "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; rv:11.0)" ) with response as file: text = decode_all(file) html = BeautifulSoup(text, features="html.parser") #data = [(e.parent.parent["class"], e) for e in html.select("div[data-image-url]")] # #first = data[0] #if "AdaptiveMedia-doublePhoto" in first[0]: amount = 2 #elif "AdaptiveMedia-triplePhoto" in first[0]: amount = 3 #elif "AdaptiveMedia-quadPhoto" in first[0]: amount = 4 #else: amount = 1 # TODO Check if format was changed # #self.src.append(first[1]["data-image-url"]) #if amount > 1: # self.meta["additional"] = [e[1]["data-image-url"] for i, e in enumerate(data) if 0 < i < amount] index = int(self._regm.group("photo_nr") or 1) - 1 data = html.select("div[tabindex='0']")[0].select( "div[data-image-url]")[index] self.src.append(data["data-image-url"])
def _fetch(self): response = make_request(self.url, "GET") with response as file: text = decode_all(file) html = BeautifulSoup(text, features="html.parser") data = html.select("a.thumb_image")[0] url = "http://e-shuushuu.net" + data["href"] self.src.append(url)
def _fetch(self): response = make_request("https://www.zerochan.net/full/" + self._regm.group("id"), "GET") # TODO Can't access nsfw pictures with response as file: text = decode_all(file) html = BeautifulSoup(text, features="html.parser") data = html.select('img[alt*="Tags"]')[0] self.src.append(data["src"])
def _fetch(self): url = "https://safebooru.org/index.php?page=dapi&s=post&q=index&limit=1&id=" + self._regm.group( "id") response = make_request(url, "GET") with response as file: text = decode_all(file) data = minidom.parseString(text).childNodes[0].childNodes[0] self.src.append("http:" + data.getAttribute("file_url")) source = data.getAttribute("source") if source and validators.url(source): self.src.append(source) rating = data.getAttribute("rating") if rating: self.meta["rating"] = rating
def _fetch(self): response = make_request( "https://danbooru.donmai.us/posts/" + self._regm["id"] + ".json", "GET") with response as file: text = decode_all(file) data = json.loads(text) if "tag_string_artist" in data: self.meta["author"] = data["tag_string_artist"] if "tag_string_character" in data: characters = data["tag_string_character"].strip() if characters: self.meta["character"] = characters.split(" ") self.meta["rating"] = data["rating"] self.meta["uid"] = data["md5"] self.src.append(data["file_url"]) if "source" in data: dsrc = data["source"] if validators.url(dsrc): self.src.append(dsrc)