def login(self, widget, data=None): user_name = self.input_name.get_text() password = self.input_passwd.get_text() if user_name == "" or password == "": Utility.toast("用户名或密码不能为空") return login_data = self.net_ease.login(user_name, Utility.md5(password)) if not login_data: Utility.toast("登录失败") return self.do_close(self)
def extractPostInfo(self, rawData): res = [] for row in csv.reader(rawData): if len(row) > 0: res.append(row[0]) #print(res) temp = {} temp['id'] = res[0] temp['extension'] = res[4] temp['title'] = res[6] temp['tag_string_artist_japanese'] = res[10] temp['tag_string_artist'] = res[41] if len(temp['tag_string_artist']) < 2: temp['tag_string_artist'] = temp['tag_string_artist_japanese'] temp['source'] = 'http://www.pixiv.net/member_illust.php?mode=medium&illust_id=' + temp['id'] temp['md5'] = utl.md5(self.localFile) temp['tag_string_general'] = res[22] + ' tag_me' temp['tag_string'] = res[22] + ' tag_me' temp['description'] = res[32] temp['tag_string_character'] = '' temp['tag_string_copyright'] = '' temp['rating'] = 's' if res[44] == '1': temp['rating'] = 'q' elif res[44] == '2': temp['rating'] = 'e' # These three values are not given. # So, set them to -1 to indicate we don't want QC to care temp['width'] = -1 temp['height'] = -1 temp['file_size'] = -1 temp['large_loc'] = res[16] temp['local_file'] = self.localFile return temp
def scrape(self): results = '' md5 = utl.md5(self.targetFile) for service in self.lookup: scraper = self.scrapers[service] scraper.setLocalFile(self.targetFile) #postID = 0 postID = scraper.findPostByMD5(md5) #print('a' + str(postID)) if postID == 0: postID = scraper.findPostByFileName(self.targetFile) #print('b' + str(postID)) if postID != 0 and scraper.postExists(postID): rawData = scraper.generateRawData(postID) if rawData != 0: tagList = scraper.extractPostInfo(rawData) #print(tagList) return tagList return 0