#我的代码:
url = 'http://wholepeople.com/best-thrift-stores-in-nyc/#:~:text=1%20Beacon%27s%20Closet.%20We%20think%20any%20thrifter%20in,...%2010%20Emma%20Rogue.%20...%20More%20items...%20'
page = urlopen(url)
soup = BeautifulSoup(page, 'html.parser')
h2Tags = soup.find_all('h2')
for store in h2Tags[:12]:
allStores = (store.text)
storeList.append(allStores)
print(storeList)
#我得到的是:
['Beacon’s Closet']
['Beacon’s Closet', 'Laced Up']
['Beacon’s Closet', 'Laced Up', '2ND Street']
['Beacon’s Closet', 'Laced Up', '2ND Street', 'Buffalo Exchange']
['Beacon’s Closet', 'Laced Up', '2ND Street', 'Buffalo Exchange', 'Tired Thrift']
['Beacon’s Closet', 'Laced Up', '2ND Street', 'Buffalo Exchange', 'Tired Thrift', 'L Train Vintage']
['Beacon’s Closet', 'Laced Up', '2ND Street', 'Buffalo Exchange', 'Tired Thrift', 'L Train Vintage', 'Cure Thrift Shop']
['Beacon’s Closet', 'Laced Up', '2ND Street', 'Buffalo Exchange', 'Tired Thrift', 'L Train Vintage', 'Cure Thrift Shop', 'Crossroads Trading']
['Beacon’s Closet', 'Laced Up', '2ND Street', 'Buffalo Exchange', 'Tired Thrift', 'L Train Vintage', 'Cure Thrift Shop', 'Crossroads Trading', 'The Attic']
['Beacon’s Closet', 'Laced Up', '2ND Street', 'Buffalo Exchange', 'Tired Thrift', 'L Train Vintage', 'Cure Thrift Shop', 'Crossroads Trading', 'The Attic', 'Emma Rogue']
['Beacon’s Closet', 'Laced Up', '2ND Street', 'Buffalo Exchange', 'Tired Thrift', 'L Train Vintage', 'Cure Thrift Shop', 'Crossroads Trading', 'The Attic', 'Emma Rogue', 'Flamingo’s Vintage Pound']
['Beacon’s Closet', 'Laced Up', '2ND Street', 'Buffalo Exchange', 'Tired Thrift', 'L Train Vintage', 'Cure Thrift Shop', 'Crossroads Trading', 'The Attic', 'Emma Rogue', 'Flamingo’s Vintage Pound', 'Monk Vintage Clothing']
#我只需要最后一份 list ,不知道为什么/如何得到我所做的