samedi 14 février 2015

Counting numbers in a list of ints [on hold]

I have a program, that gives me random numbers, and I want to count how many numbers of 1 kind that RNG gives me.


It goes something like this RNG = 1,3,6,4,8,1,8,5,2,7,1. What I want to see = 1 three, 8 two, 2 one, 3 one, 4 one, 5 one, 6 one, 7 one.


Is this even doable ? Thank you.


Adding the code (i want to count how many links are the same kind).



import requests
from bs4 import BeautifulSoup

def webpages():

url = 'http://ift.tt/1yBrlq9'
source_code = requests.get(url)
text = source_code.text
soup = BeautifulSoup(text)
for link in soup.findAll ('a', {'class':' ', 'rel':'nofollow'}):
href = link.get('href')
print(href)
get_single_item_data(href)

def get_single_item_data(item_url):
source_code = requests.get(item_url)
text = source_code.text
soup = BeautifulSoup(text)
for link in soup.findAll('a'):
href = link.get('href')
print(href)

webpages()




Aucun commentaire:

Enregistrer un commentaire