-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b03cc0
commit 21ece89
Showing
33 changed files
with
222 additions
and
49 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Empty file.
Empty file.
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from bs4 import BeautifulSoup | ||
import urllib.request | ||
import sqlite3 | ||
from datetime import datetime | ||
|
||
|
||
# conn = sqlite3.connect('beautiful_soup/example2.db') | ||
conn = sqlite3.connect('example2.db') | ||
c = conn.cursor() | ||
# c.execute('''drop table bloom''') | ||
c.execute('''CREATE TABLE IF NOT EXISTS bloom | ||
(date text, name text, price real)''') | ||
|
||
# Save (commit) the changes | ||
conn.commit() | ||
|
||
url = ['http://207.246.85.12/nasdaq.html', 'http://207.246.85.12/500.html'] | ||
data = [] | ||
for pg in url: | ||
# page = urllib.request.urlopen(pg) | ||
page = urllib.request.urlopen(pg) | ||
|
||
# urllib2 is python 2 only | ||
# Finally, parse the page into BeautifulSoup format so we can use | ||
# BeautifulSoup to work on it. | ||
|
||
# parse the html using beautiful soup and store in variable `soup` | ||
soup = BeautifulSoup(page, 'html.parser') | ||
|
||
# Take out the <div> of name and get its value | ||
name_box = soup.find('h1', attrs={'class': 'name'}) | ||
|
||
# After we have the tag, we can get the data by getting its text. | ||
|
||
# strip() is used to remove starting and trailing | ||
name = name_box.text.strip() | ||
|
||
print(name) | ||
|
||
# Similarly, we can get the price too. | ||
|
||
price_box = soup.find('div', attrs={'class': 'price'}) | ||
price = price_box.text | ||
print(price) | ||
stockers = ([name, price]) | ||
# stockers = ([name, price, datetime.now()]) | ||
print(stockers) | ||
bugger = len([name, price]) | ||
print(bugger) | ||
|
||
# Now lets insert some data | ||
ins = conn.cursor() | ||
ins.execute('INSERT INTO bloom(name, price, date) VALUES(?,?,?)', | ||
[name, price, datetime.now()]) | ||
id = ins.lastrowid | ||
print('Last row id: %d' % id) | ||
conn.commit() | ||
|
||
for row in c.execute('SELECT * FROM bloom ORDER BY date'): | ||
print(row) | ||
|
||
# We can also close the connection if we are done with it. | ||
# Just be sure any changes have been committed or they will be lost. | ||
conn.close() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
files = ["Best", "Common", ] | ||
mystuff = [ | ||
"hersd", | ||
"rfewr", | ||
"werwv", | ||
"w657657", | ||
"6867534", ] | ||
for thing in files: | ||
print("I like... \n", | ||
thing) | ||
print("What is happening?") | ||
for blah in mystuff: | ||
print("blue is a cosmic anomoly", blah) |
Empty file.
Empty file.
Binary file not shown.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.