wikiHowUnofficialAPI
version 0.1.1
Wikihowunofficilapi旨在提供基于Python的界面,以易于使用的方式从Wikihow文章(例如文章摘要,步骤,图像等)中提取有用的信息。
pip install wikiHowUnofficialAPI学习随机的东西!重新调整随机Wikihow文章URL。
import wikihowunofficialapi as wha
ra = wha . random_article ()
print ( ra )使用文章URL返回有关文章的各种细节。此外,它还返回文章是否由专家撰写。
import wikihowunofficialapi as wha
article = wha . Article ( 'https://www.wikihow.com/Train-a-Dog' )
print ( article . url ) # Print Article's URL
print ( article . title ) # Print Article's Title
print ( article . intro ) # Print Article's Introduction
print ( article . n_methods ) # Print number of methods in an Article
print ( article . methods ) # Print a list of methods in an Article
print ( article . num_votes ) # Print number of votes given to an Article
print ( article . percent_helpful ) # Print percentage of helpful votes given to an Article
print ( article . is_expert ) # Print True if the Article is written by an expert
print ( article . last_updated ) # Print date when the Article was last updated
print ( article . views ) # Print the number of views recieved by Article
print ( article . co_authors ) # Print the number of co-authors of an Article
print ( article . references ) # Print the number of references in an Article
print ( article . summary ) # Print Article's summary
print ( article . warnings ) # Print Article's warnings
print ( article . tips ) # Print Article's tips
first_method = article . methods [ 0 ]
first_step = first_method . steps [ 0 ]
print ( first_step ) # Print Article's first step of the first method
print ( first_step . title ) # Print the title of Article's first step of the first method
print ( first_step . description ) # Print the description of Article's first step of the first method检索一步中包含的图像列表。
import wikihowunofficialapi as wha
article = wha . Article ( 'https://www.wikihow.com/Train-a-Dog' )
print ( article . methods [ 0 ]. steps [ 0 ]. picture ) # Print the URL of the image of Article's first step of the first method搜索Wikihow for String,并返回包含文章标题的列表。默认最大结果为10,但可以更改。
import wikihowunofficialapi as wha
max_results = 1
how_tos = wha . search_wikihow ( "sleep" , max_results )
print ( how_tos [ 0 ])