本文整理汇总了Python中Person.Person.follow方法的典型用法代码示例。如果您正苦于以下问题:Python Person.follow方法的具体用法?Python Person.follow怎么用?Python Person.follow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person.Person
的用法示例。
在下文中一共展示了Person.follow方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_data
# 需要导入模块: from Person import Person [as 别名]
# 或者: from Person.Person import follow [as 别名]
def get_data():
url = next_urls.pop().replace('\n', '')
if url in seen_urls:
return
print(url)
person = Person(url, session)
try:
person.get_all_info()
except:
print('Get user data error!')
return
print(person.id, person.name, person.url, person.gender, person.location, person.business,
person.employment, person.position, person.education, person.education_extra,
person.description, person.hash_id,
person.follower_num, person.followee_num, person.asks, person.answers, person.posts,
person.collections, person.logs, person.agrees, person.thanks)
data = (person.id, person.name, person.url, person.gender, person.location, person.business,
person.employment, person.position, person.education, person.education_extra,
person.description, person.hash_id,
person.follower_num, person.followee_num, person.asks, person.answers, person.posts,
person.collections, person.logs, person.agrees, person.thanks)
try:
db.insert_data(data)
except pymysql.err.DataError as E:
print(E)
return
next_urls.update(person.follow())
seen_urls.add(url)
print(len(next_urls))
# 爬取一百人之后更新一次next_urls.txt文件,实时保存进度
if len(next_urls) % 100 == 0:
save_next_urls()
save_seen_urls(url)