Created
May 25, 2017 16:14
-
-
Save JackInTaiwan/d4e8bbd53be5322fd3abf650447d3249 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding: utf-8 -*- | |
import urllib2 as url2 | |
from bs4 import BeautifulSoup | |
import re | |
import requests | |
#from vpython import * # !!! MUST import this,otherwise you're NOT allowed to use curve or others!!! | |
from visual import * | |
from visual.graph import * | |
res = list() | |
for i in range(1,47): | |
url ="http://www.lotto-8.com/listltobig.asp?indexpage="+str(i)+"&orderby=new" | |
try: | |
response = requests.post(url) | |
soup = BeautifulSoup(response.text, "html.parser") | |
all = soup.find_all(name="td", attrs={"class":"auto-style5","style":"border-bottom-style: dotted; border-bottom-color: #CCCCCC; font-size:36px;"} ) | |
for content in all: | |
content = content.string.split(u"\xa0") | |
for item in content: | |
if item!=u",": | |
res.append(item) | |
except url2.URLError, e: | |
pass | |
statis = [0 for i in range(50)] | |
for item in res: | |
statis[int(item)] +=1 | |
g1 = gdisplay() | |
g2 = gdisplay() | |
f1 = gvbars(gdisplay=g1) | |
f2 = gvbars(gdisplay=g2) | |
for x in range(1,50,+1): | |
f1.plot(pos=(x,statis[x])) | |
f2.plot(pos=(x,sorted(statis)[x])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment