خرید بک لینک

Vote count: 0

from bs4 import BeautifulSoup
import urllib2
# Imported libraries for future use.
response = urllib2.urlopen('http://www.nytimes.com').read()
soup = BeautifulSoup(response,"lxml")

host = []
#created empty list to append future words extracted from data set.
for story_heading in soup.find_all(class_="story-heading"):
    story_title = story_heading.text.replace("n", " ").strip()
    new_story_title = story_title.encode('utf-8')


    parts = new_story_title.split()[0]

    i=['a','A','an','An','the','The','from','From','to','To','when','When','what','What','on','On','for','For']
    if parts not in i:
        host.append(parts)
    else:
        pass
#now i have to calculate the number of repeated words in the file and calcute the number of repeatation.    
print host

let me know how to calculate the number of repeated words in list we created. actually am pretty confused about the above code too. if anyone can explain what i did mistake in it, it would be greatful

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 7 ارديبهشت 1395 ساعت: 13:09

صفحه بندی