我已经计划了一个简单的html页面,它可以将书名作为用户的输入,只需点击一下按钮即可返回该书的评论。我使用python的beautifulsoup从goodreads api中提取评论。以下是代码:
from bs4 import BeautifulSoup
import requests
bookname = raw_input("Enter the book's name ")
r = requests.get("https://www.goodreads.com/book/title.xml?&key=lrMttFP2MxZPfHgvb5TiA&title=" +bookname)
data = r.text
soup = BeautifulSoup(data ,"html.parser")
print(soup.description.get_text())
现在我需要直接从html页面获取输入(bookname)并在同一页面上返回结果评论。