Beispiel #1
0
def main():
    all_items = []
    #NYTimes sections corresponding to Downtime categories
    #Categories = Arts, Sports, Tech, Entertainment, Finance, World
    #Corresponding to NYTimes sections = Arts, ___,  Technology, Style, Business, World
    for x in nytimes_urls("Arts"): all_items.append(x)
    for x in nytimes_urls("Sports"): all_items.append(x)
    for x in nytimes_urls("Technology"): all_items.append(x)
    for x in nytimes_urls("Style"): all_items.append(x)
    for x in nytimes_urls("Business"): all_items.append(x)
    for x in nytimes_urls("World"): all_items.append(x)

    #print all_items
    #write all items
    write_items(all_items)
    dir(all_items)
    return all_items
Beispiel #2
0
	#open our url, load the JSON
	response = urlopen(url)
	json_obj = load(response)

	items = []
	textLength=0.
	#parse our story

	item = Item()

	for story in json_obj['list']['story']:
		title = story['title']['$text']
		link = story['link'][0]['$text']
		
        item.name = title
        item.url = link
        print link
        item.add_tag("world")
    
	for paragraph in story['textWithHtml']['paragraph']:
		text = paragraph['$text']
		textLength +=len(text)

	time = durationfunctionstupid(requests.get(url).text)
	item.duration = time
	items.append(item)
	return items

if __name__ == "__main__":
	write_items(search_npr(1003))
Beispiel #3
0
    while (i<len(s)): 
        #print is_number(not "1"[0])
        while (is_number(s[i])):
            #print s[i]
            #print a
            a*=10
            a+=ord(s[i])-ord('0')
            i+=1
        out[s[i]]=a
        a=0
        i+=1
    return out    

def fmt_num(num):
    return 360**num["H"]+60*num["M"]+num["S"]

            
if __name__=='__main__':
    items = search_youtube(sys.argv[0])
    write_items(items)


    
      
      
    
    
    

    
Beispiel #4
0
def yahoo_add_db(keyword_list, number_each):
    url_dict=yahoo_best_urls(keyword_list, number_each)
    write_items(url_dict);           
Beispiel #5
0
    for a in range(len(final_games)):
        conn = urllib2.urlopen(final_games[a])
        html = conn.read()
        soup = BeautifulSoup(html)
        links = soup.find(id="time")
        url_for_times.append(links)
    url_times = zip(final_games, url_for_times)
    return url_times

def parse_times_and_urls(url_times):
    regex = re.compile("\">(?P<time>\d\d\:\d\d)")
    times = [regex.findall(i[1])[0] for i in url_times]    
    times = [time[0] for time in times]
    urls = [i[0] for i in url_times]
    for a in urls:
        item = Item()
        item.duration = times[a]
        item.url = urls[a]
        soup = BeautifulSoup(html)
        name = soup.find_all(re.compile("^h2"))
        item.name = name
        item.add_tag("game")
        items.append(item)
    return items
    #need to test this part to see if Item works  

if __name__=='__main__':
    write_items(parse_times_and_urls(find_times_and_urls()))