def _getTotalArtCount(self, artist): basePage = "http://www.furaffinity.net/user/%s/" % artist page = self.wg.getSoup(basePage) pgstr = str(page) if 'has voluntarily disabled access to their account and all of its contents.' in pgstr: self.log.warning("Disabled account!") raise exceptions.AccountDisabledException( "Could not retreive artist item quantity!") if 'The page you are trying to reach has been deactivated by the owner.' in pgstr: self.log.warning("Disabled account!") raise exceptions.AccountDisabledException( "Could not retreive artist item quantity!") if 'This user cannot be found.' in pgstr: self.log.warning("Account not found!") raise exceptions.AccountDisabledException( "Could not retreive artist item quantity!") # This is HORRIBLE containers = page.find_all("div", class_="userpage-section-right") for container in containers: if container.h2 and "Stats" in container.h2.get_text(strip=True): for div_section in container.find_all("div", class_='cell'): for span in div_section.find_all("span"): if span and "Submissions" in span.get_text(strip=True): num = str(span.next_sibling) return int(num) raise exceptions.AccountDisabledException( "Could not retreive artist item quantity!")
def _getTotalArtCount(self, artist): basePage = "http://www.furaffinity.net/user/%s/" % artist page = self.wg.getSoup(basePage) pgstr = str(page) if 'has voluntarily disabled access to their account and all of its contents.' in pgstr: self.log.warning("Disabled account!") raise exceptions.AccountDisabledException("Could not retreive artist item quantity!") if 'The page you are trying to reach has been deactivated by the owner.' in pgstr: self.log.warning("Disabled account!") raise exceptions.AccountDisabledException("Could not retreive artist item quantity!") if 'This user cannot be found.' in pgstr: self.log.warning("Account not found!") raise exceptions.AccountDisabledException("Could not retreive artist item quantity!") tds = page.find("td", align="right", text="Statistics") stats = tds.parent.parent.text for line in stats.splitlines(): line = line.rstrip(" ").lstrip(" ") if "Submissions: " in line: num = line.split(":")[-1] return int(num) raise exceptions.AccountDisabledException("Could not retreive artist item quantity!")
def __getTotalArtCount(self, artist): aid = int(artist) items = self.papi.users_works(aid, include_stats=False) if items['status'] != 'success': if items.get("errors", {}).get('system', {}).get('message') == 404: raise exceptions.AccountDisabledException( "Got 404 when trying to get art count") if items.get("errors", {}).get('system', {}).get('message') == '404 Not Found': raise exceptions.AccountDisabledException( "Got 404 when trying to get art count") # This /seems/ to indicate suspended accounts. if items.get("errors", {}).get('system', {}).get('code') == 971: raise exceptions.AccountDisabledException("Account suspended?") self.log.error( "Error while attempting to get artist gallery content for ID %s!!", artist) for line in traceback.format_exc().split("\n"): self.log.error(line) for line in pprint.pformat(items).split("\n"): self.log.error(line) raise exceptions.NotLoggedInException("Failed to get artist page?") return items['pagination']['total']
def _getTotalArtCount(self, artist): basePage = "https://{user}.newgrounds.com/".format(user=artist) try: page = self.wg.getSoup(basePage) except WebRequest.FetchFailureError as e: if e.err_code == 404: raise exceptions.AccountDisabledException( "Account seems to have been removed!") raise e # Try for stats first, then see if we need to bounce stats = page.find('div', class_='scroll-area') if not stats: return None for header_btn in stats.find_all('a', class_='user-header-button'): dtype = header_btn.find("span").get_text(strip=True) dval = header_btn.find("strong").get_text(strip=True) if dtype == 'ART': ret = int(dval) self.log.info("Artist %s should have %s gallery items.", artist, ret) return ret soups = str(page) no_items = page.find('p', class_='padded-message') if no_items: if "We have yet to see how {} will contribute to the site.".format( artist).lower() in no_items.get_text(strip=True).lower(): raise exceptions.NoArtException("No art for artist yet!") return None
def _getTotalArtCount(self, artist): basePage = "http://www.pixiv.net/member_illust.php?id=%s" % artist page = self.wg.getSoup(basePage) mainDiv = page.find("div", class_="layout-a") if not mainDiv: raise exceptions.AccountDisabledException( "Could not retreive artist item quantity!") countSpan = mainDiv.find("span", class_="count-badge") if not countSpan: raise exceptions.AccountDisabledException( "Could not retreive artist item quantity!") text = countSpan.text.split()[0] text = ''.join([char for char in text if char in '0123456789']) return int(text)
def _getTotalArtCount(self, artist): basePage = "http://www.hentai-foundry.com/user/%s/profile" % artist try: page = self.wg.getSoup(basePage) except WebRequest.FetchFailureError as e: if e.err_code == 404: raise exceptions.AccountDisabledException("Account seems to have been removed!") raise e tds = page.find("b", text="# Pictures") stats = tds.parent.parent.find("td", text=re.compile(r"^\d+$")) if stats: return int(stats.text) raise exceptions.AccountDisabledException("Could not retreive artist item quantity!")
def _getTotalArtCount(self, artist): basePage = 'https://inkbunny.net/{user}'.format(user=artist) page = self.wg.getSoup(basePage) stats = page.find('span', class_='stat', title='Submissions Uploaded') if stats and stats.strong: return int(stats.strong.get_text().replace(",", "")) raise exceptions.AccountDisabledException("Could not retreive artist item quantity!")
def _getTotalArtCount(self, artist): basePage = "http://www.hentai-foundry.com/user/%s/profile" % artist page = self.wg.getSoup(basePage) tds = page.find("b", text="# Pictures") stats = tds.parent.parent.find("td", text=re.compile(r"^\d+$")) if stats: return int(stats.text) raise exceptions.AccountDisabledException("Could not retreive artist item quantity!")
def _getTotalArtCount(self, artist): try: soup = self.wg.getSoup("https://%s.sofurry.com/" % artist.strip().lower()) except WebRequest.FetchFailureError as e: if e.err_code == 404: raise exceptions.AccountDisabledException("Account seems to have been removed!") raise e # This is probably stupidly brittle subdiv = soup.find("span", class_='sfTextMedLight', text=re.compile('submissions', flags=re.IGNORECASE)) tgt = subdiv.parent.span.get_text() # Dump number separators tgt = tgt.replace(",", "") return (int(tgt))
def _getTotalArtCount(self, artist): # Apparently users can turn this off? F*****g annoying. basePage = "https://www.weasyl.com/~{user}".format(user=artist) page = self.wg.getSoup(basePage) stats = page.find('div', id='user-stats') if not stats: return None item = stats.find("dd", text='Submissions') if not item: return None if item: # This feels a bit brittle, but I can't see how else to get the row # I want. items = item.previous_sibling.previous_sibling.get_text() return int(items) raise exceptions.AccountDisabledException("Could not retreive artist item quantity!")