We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
加在user类里。。最好把我写的代码改一下再加进去,或者再加个topic类啥的 python def get_topics_num(self): if self.user_url == None: print "I'm anonymous user." return 0 else: if self.soup == None: self.parser() soup = self.soup try: topics_num = soup.find_all("div", class_="zm-profile-side-section-title")[1].strong.string.encode("utf-8") I='' for i in topics_num: if i.isdigit(): I=I+i topics_num=int(I) return topics_num except: print self.get_user_id() return 0
python
def get_topics(self): if self.user_url == None: print "I'm anonymous user." return else: topics_num = self.get_topics_num() print topics_num if topics_num == 0: return "" else: for i in xrange((topics_num - 1) / 20 + 1): topics_url = self.user_url + "/topics" r = requests.get(topics_url) lovetopic="" soup = BeautifulSoup(r.content) for topics in soup.find_all("div", class_="zm-profile-section-item zg-clear"): name =topics.find("strong").string.encode("utf-8") lovetopic=lovetopic+name+"|" return lovetopic
The text was updated successfully, but these errors were encountered:
No branches or pull requests
加在user类里。。最好把我写的代码改一下再加进去,或者再加个topic类啥的
python
def get_topics_num(self):
if self.user_url == None:
print "I'm anonymous user."
return 0
else:
if self.soup == None:
self.parser()
soup = self.soup
try:
topics_num = soup.find_all("div", class_="zm-profile-side-section-title")[1].strong.string.encode("utf-8")
I=''
for i in topics_num:
if i.isdigit():
I=I+i
topics_num=int(I)
return topics_num
except:
print self.get_user_id()
return 0
The text was updated successfully, but these errors were encountered: