I am Learning Python.

Linked-In Learning Python   https://github.com/LinkedInLearning/learning-python-2896241

learning-python-2896241-main https://www.linkedin.com/learning/learning-python-14393370/exercise-files

https://docs.python-requests.org/en/latest/index.html

python -m pip install requests

>>> import requests
>>> r = requests.get('https://api.github.com/user', auth=('user', 'pass'))
>>> r.status_code
401
>>>

https://core-electronics.com.au/tutorials/python-workshop.html

Python Workshop for Beginners

By , updated on 

https://darksky.net/forecast/-37.5617,143.8548/ca24/en Ballarat Forcast

 

 

 

web scraping

https://helpdeskgeek.com/how-to/how-to-scrape-a-website/

 

https://github.com/karramsos/Web-Scarping-with-Python-Course/blob/master/Crawling/wikipedia_links_complete.py

You can get it here: https://github.com/karramsos - enjoy!

from urllib.request import urlopen
from bs4 import BeautifulSoup
import datetime
import random
import re
random.seed(datetime.datetime.now())
def getLinks(articleUrl):
html = urlopen("http://en.wikipedia.org"+articleUrl)
bsObj = BeautifulSoup(html, "lxml")
return bsObj.find("div", {"id":"bodyContent"}).findAll("a", href=re.compile("^(/wiki/)((?!:).)*$"))
links = getLinks("/wiki/Kevin_Bacon")
while len(links) > 0:
newArticle = links[random.randint(0, len(links)-1)].attrs["href"]
print(newArticle)
links = getLinks(newArticle)

 

from urllib.request import urlopen
from bs4 import BeautifulSoup
import datetime
import random
import re

random.seed(datetime.datetime.now())
def getLinks(articleUrl):
html = urlopen("http://en.wikipedia.org"+articleUrl)
bsObj = BeautifulSoup(html, "lxml")
return bsObj.find("div", {"id":"bodyContent"}).findAll("a", href=re.compile("^(/wiki/)((?!:).)*$"))
links = getLinks("/wiki/Kevin_Bacon")
while len(links) > 0:
newArticle = links[random.randint(0, len(links)-1)].attrs["href"]
print(newArticle)
links = getLinks(newArticle)

 

 

 

 

 

 

 

 

 

 

 

I want to screen scrape

https://speakerdeck.com/pycon2017 Slides from Py.com 2017

https://speakerdeck.com/pycon2017/al-sweigart-yes-its-time-to-learn-regular-expressions?slide=8

Installing Visual Studio Code Editor for Python https://code.visualstudio.com/docs/python/python-tutorial

Firedays (Why did I not document the code to do this)

I found the code to the firedays program

There is this concept of the pythonic way of doing things which is codified in stuff like PEP8 and other python enhancement proposals. Possibly worth having a read as there are some good tricks and practices in there.

Automate Python Scripts in Windows

Learn Ptyhon The Hard Way Subscription details Learn Ptyhon the hard way Book

The login is my email address
rupert@rupert.id.au

The  video tutorials are online at: https://shop.learncodethehardway.org/products/contents/9/

 

 

2019_08_18_CoffeeBreakPython_paperback_version

CheatSheet-Python-1_-Keywords1

CheatSheet-Python-2_-Data-Structures.docx

CheatSheet-Python-3_-Complex-Data-Types

CheatSheet-Python-4_-Classes

CheatSheet-Python-5_-Functions-and-Tricks

CheatSheet-Python-6_-Coding-Interview-Questions

CheatSheet-Python-7_-NumPy-1

Finxter_WorldsMostDensePythonCheatSheet

 

>>> import pyautogui
>>> pyautogui.mouseInfo()

Unix: python3 -m mouseinfo

https://automatetheboringstuff.com/2e/chapter20/

 

 

https://mechanicalsoup.readthedocs.io/en/stable/introduction.html#installation

 

https://automatetheboringstuff.com/

Order complete

Your order is complete! Your order number is 182069. Thank you for shopping at No Starch Press. Your current order has been attached to the account we found matching your e-mail address. Login to view your current order status and order history. Remember to login when you make your next purchase for a faster checkout experience! If your order included any ebooks, you can download them at any time from the Files tab in your account. Learn more about ebooksReturn to the front page.

rupert,
Thank you for registering at No Starch Press. You may now log in to https://nostarch.com/user using the following username:
username: rupert

Automate2e PDF

Automate2e Mobi

Automate2e ePub

 

>>> import pyautogui

>>> pyautogui.mouseInfo()

 

 

 

Run Power Shell

Change Diectory to C:\Doc\p\python

python ex1.py

 

Power Shell Commands eg: Get-CimInstance -ClassName Win32_ComputerSystem

 

 

From: https://www.youtube.com/watch?v=0sOfhhduqks&feature=emb_err_woyt

 

 

Counting Things:

https://codefisher.org/catch/blog/2015/04/22/python-how-group-and-count-dictionaries/

from collections import Counter
names = ["mark", "john", "john", "mark", "fred", "paul", "john", "rupert", "rupert","rupert","rupert",]
d = Counter(names)
print(d)

 

this returns a dict-like object (a dict subclass actually), which should be good enough for our purposes, so we’ll stick with it.

 

Count and sort

 

 

---

 

Hotkeys for AIKEN file conversion

#! python3
# Automatically replace
# a with ANSWER: A
# b with ANSWER: B
# c with ANSWER: C
# d with ANSWER: D

# https://pypi.org/project/keyboard/

import keyboard
import pyautogui

def on_triggered_1():
pyautogui.press('backspace')
pyautogui.press('enter')
pyautogui.press('enter')
pyautogui.press('enter')
pyautogui.write('ANSWER: A')
pyautogui.press('enter')

keyboard.add_hotkey('a', on_triggered_1)

def on_triggered_2():
pyautogui.press('backspace')
pyautogui.press('enter')
pyautogui.press('enter')
pyautogui.press('enter')
pyautogui.write('ANSWER: B')
pyautogui.press('enter')

keyboard.add_hotkey('b', on_triggered_2)

def on_triggered_3():
pyautogui.press('backspace')
pyautogui.press('enter')
pyautogui.press('enter')
pyautogui.press('enter')
pyautogui.write('ANSWER: C')
pyautogui.press('enter')

keyboard.add_hotkey('c', on_triggered_3 )

def on_triggered_4():
pyautogui.press('backspace')
pyautogui.press('enter')
pyautogui.press('enter')
pyautogui.press('enter')

pyautogui.write('ANSWER: D')
pyautogui.press('enter')

keyboard.add_hotkey('d', on_triggered_4 )

def on_triggered_5():
pyautogui.press('backspace')
pyautogui.press('enter')
pyautogui.press('enter')
pyautogui.press('enter')

pyautogui.write('ANSWER: E')
pyautogui.press('enter')

keyboard.add_hotkey('e', on_triggered_5 )

print("Press ESC to stop.")
keyboard.wait('esc')

---

Parse a Google Maps URL to extract the destinatin northing & easting

https://www.google.com/maps/dir/-37.5639106,143.8689047/-37.5766292,143.8638248/@-37.5680181,143.8640266,15.32z/data=!4m2!4m1!3e0

 

https://www.google.com/maps/dir/-37.5639106,143.8689047/-37.5766292,143.8638248/@-37.5680181,143.8640266,15.32z/data=!4m2!4m1!3e0
eventEasting = 143.8638248
eventNorthing = -37.5766292

 

 

https://core-electronics.com.au/raspberry-pi-pico.html

https://micropython.org/

MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimised to run on microcontrollers and in constrained environments.

 

 

 

Computer Vision in Python Tutorial

Open and display images & Video

Rescale/resize Images & Video

Draw Shapes and add text to Video & Images

Image Transformation Trnaslation,

 

 

 

https://github.com/eleanorlutz/topography_atlas_of_space

 

 

Using Python with Excel Linked In Learning

 

Run PowerShell

Win + R > Powershell

use pip to install openpyxl

 

step1.py

 

regions.xlsx

 

reading regions.xlsx into a data frame df_ and printing the data frame

import pandas as pd

from openpyxl.workbook import Workbook

df_excel = pd.read_excel('regions.xlsx')
df_csv = pd.read_csv('Names.csv')
df_text = pd.read_csv('data.txt')

print(df_excel)

 

Names.csv

print(df_csv)

 

data.txt

 

print(df_text)