Skip to content

Commit

Permalink
Added more workouts
Browse files Browse the repository at this point in the history
  • Loading branch information
johnzastrow committed Aug 29, 2018
1 parent 9b03cc0 commit 21ece89
Show file tree
Hide file tree
Showing 33 changed files with 222 additions and 49 deletions.
Empty file modified .gitattributes
100755 → 100644
Empty file.
Empty file modified .gitignore
100755 → 100644
Empty file.
Empty file modified .idea/LearningPy.iml
100755 → 100644
Empty file.
Empty file modified .idea/misc.xml
100755 → 100644
Empty file.
Empty file modified .idea/modules.xml
100755 → 100644
Empty file.
Empty file modified .idea/vcs.xml
100755 → 100644
Empty file.
194 changes: 145 additions & 49 deletions .idea/workspace.xml
100755 → 100644

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified .vscode/settings.json
100755 → 100644
Empty file.
Empty file modified README.md
100755 → 100644
Empty file.
Empty file modified age.py
100755 → 100644
Empty file.
Empty file modified base_selen.py
100755 → 100644
Empty file.
Empty file modified bday.py
100755 → 100644
Empty file.
Empty file modified beautiful_soup/beautiful.py
100755 → 100644
Empty file.
64 changes: 64 additions & 0 deletions beautiful_soup/beautiful2db.py
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()
13 changes: 13 additions & 0 deletions beautiful_soup/checkmypys.py
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 modified beautiful_soup/db_utils.py
100755 → 100644
Empty file.
Empty file modified beautiful_soup/example.db
100755 → 100644
Empty file.
Binary file added beautiful_soup/example2.db
Binary file not shown.
Empty file modified beautiful_soup/index.csv
100755 → 100644
Empty file.
Empty file modified beautiful_soup/index.html
100755 → 100644
Empty file.
Empty file added beautiful_soup/inmates.py
Empty file.
Empty file modified beautiful_soup/killit.py
100755 → 100644
Empty file.
Empty file modified beautiful_soup/quixk.sql
100755 → 100644
Empty file.
Empty file modified beautiful_soup/sqlite_testing.py
100755 → 100644
Empty file.
Empty file modified beautiful_soup/test_dbfunc.py
100755 → 100644
Empty file.
Empty file modified days.txt
100755 → 100644
Empty file.
Empty file modified dicts.py
100755 → 100644
Empty file.
Empty file modified example.db
100755 → 100644
Empty file.
Empty file modified index.csv
100755 → 100644
Empty file.
Empty file modified journal.py
100755 → 100644
Empty file.
Empty file modified lsi.py
100755 → 100644
Empty file.
Empty file modified mantis_bak.py
100755 → 100644
Empty file.
Empty file modified playground.py
100755 → 100644
Empty file.

0 comments on commit 21ece89

Please sign in to comment.