如何在VS代码终端中传递参数? (漂亮的汤脚本)

时间:2019-07-05 10:05:17

标签: python visual-studio-code arguments

我想知道如何调用此脚本并在VS代码中传递参数。 有谁知道该怎么做?

import requests
from bs4 import BeautifulSoup

# scrape_url =  https://www.goodreads.com/book/show/39863447

def scrapeGoodreads(scrape_url):
    # get the data
    data = requests.get('scrape_url')

    #load the data into bs4
    soup = BeautifulSoup(data.text, 'html.parser')

    #Acces the div block which contains the relevant content
    content = soup.find('div',{'id':'topcol'})

    #Grab the needed text/url's from the content div block
    title = content.find('h1',{'id':'bookTitle'}).text.strip()
    author = content.find('a',{'class':'authorName'}).text.strip()
    avgRating = content.find('span',{'itemprop':'ratingValue'}).text.strip()
    ratingCount = content.meta['content']
    coverUrl = content.img['src']
    amazonUrl = content.find('a',{'class':'buttonBar'})['href']

    #print all the arguments in 1 statement 
    print('Title: %s \nAuhtor: %s \nBook cover: %s \nAverage rating: %s \nTotal ratings: %s \nAmazon url: %s' % (title, author, coverUrl,avgRating, ratingCount, amazonUrl))

scrapeGoodreads()

0 个答案:

没有答案