codingforentrepreneurs / 30-days-of-python Goto Github PK
View Code? Open in Web Editor NEWLearn Python for the next 30 (or so) Days.
Home Page: https://cfe.sh/projects/30-days-python-38
License: MIT License
Learn Python for the next 30 (or so) Days.
Home Page: https://cfe.sh/projects/30-days-python-38
License: MIT License
my csv file written with python has blank lines between each row
Selenium made several changes, especially to find_element and find_elements and they depreciated the find_by_* calls.
Documentation on "https://selenium-python.readthedocs.io/installation.html" is outdated
Best Documentation can be found on "https://www.selenium.dev/documentation/webdriver/elements/locators/"
The following code can log users into Instagram and clear the 2 messages as of 27 Sept 2023
HTH
`import getpass
#my_password = getpass.getpass("What's your password?\n")
#print(my_password)
from conf import INSTA_USERNAME, INSTA_PASSWORD
from selenium import webdriver
from selenium.webdriver.common.by import By ##***Helpful in 4.3.
import time
browser = webdriver.Chrome()
url = 'https://instagram.com'
browser.get(url)
time.sleep(1)
username_el = browser.find_element(By.NAME,'username').send_keys(INSTA_USERNAME)
password_el = browser.find_element(By.NAME,'password').send_keys(INSTA_PASSWORD)
submit_btn_el = browser.find_element(By.XPATH, "//button[@type='submit']");
time.sleep(1)
submit_btn_el.click()
time.sleep(3)
body_el = browser.find_element(By.CSS_SELECTOR,"body")
html_text = body_el.get_attribute("innerHTML")
"""
Need to clear the Save your login
not_now_el = browser.find_element(By.XPATH, "//div[contains(text(),'Not Now')]")
not_now_el.click()
"""
Also need to clear the Turn on Notifications
"""
notifications_not_now_el = browser.find_element(By.XPATH, "//button[contains(text(),'Not Now')]")
notifications_not_now_el.click()
`
yelp_soup=BeautifulSoup(yelp_r.text,'html.parser')
print(yelp_soup.prettify())
Traceback (most recent call last):
File "", line 1, in
File "C:\Python34\lib\encodings\cp437.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2019' in position 33349: character maps to
it is day16 practise:
with open(filename,"rb") as csvfile,temp_file:
i got error as below:
Traceback (most recent call last):
File "rw_CSV_function.py", line 56, in
edit_data(email="[email protected]",amount=99.99,sent="")
File "rw_CSV_function.py", line 38, in edit_data
writer.writeheader()
File "C:\Python36\lib\csv.py", line 144, in writeheader
self.writerow(header)
File "C:\Python36\lib\csv.py", line 155, in writerow
return self.writer.writerow(self._dict_to_list(rowdict))
File "C:\Python36\lib\tempfile.py", line 483, in func_wrapper
return func(*args, **kwargs)
TypeError: a bytes-like object is required, not 'str'
i don't know how to fix this problem, can u please help me?
Traceback (most recent call last):
File "", line 28, in
File "C:\Python36\lib\os.py",
line 210, in makedirs
makedirs(head, mode, exist_ok)
File "C:\Python36\lib\os.py",
line 220, in makedirs
mkdir(name, mode)
OSError: [WinError 123] The filename, directory name, or volume label syntax is
incorrect: 'C:\Python36\emails\Thu, 30 Jul 2015 21:50:34 -0700'
Upon running the scipt, I got 2 errors:
UnicodeEncodeError: 'charmap' codec can't encode character <some-character> in position <some-position>: character maps to <undefined>
SOLUTION: add following parameter to output_file.write_text(...)
: encoding="utf-8"
RuntimeError: Event loop is closed
Did anyone resolve this error?
It seems that Yelp has change their API to 「Yelp Fusion 」
The example code isn't working
Anybody have the same problem?
Hi,
Facing an error in Day-11 Tutorial in templates.py file.
NameError: name 'template_path' is not defined
Traceback (most recent call last):
File "scrape.py", line 96, in
run(start_year=start, years_ago=count)
File "scrape.py", line 77, in run
finished = parse_and_extract(url, name=start_year)
File "scrape.py", line 56, in parse_and_extract
table_data_dicts.append(row_dict_data)
NameError: name 'table_data_dicts' is not defined
When running the download_from_url.py
, an error occurs:
Traceback (most recent call last): File "download_from_url.py", line 27, in <module> download_file(url, DOWNLOADS_DIR) File "/private/tmp/30-Days-of-Python/tutorial-reference/Day 10/download_util.py", line 12, in download_file return new_dl_path NameError: name 'new_dl_path' is not defined
Changing the new_dl_path
variable name to dl_path
in download_util.py
solves the issue.
For code in Classes 3 Day 9 it is showing "missing 2 required positional arguments python" after compiling. `import datetime
class MessageUser():
user_details = []
messages = []
base_message = """
Hi {name}!
Its been good to have you with us on {date} for the course.
The total amount for your course is Rs.{total}.
Have a great day !!!
"""
def add_user(self, name, amount):
amount = "%.2f" %(amount)
detail = {
"name": name,
"amount": amount,
}
today = datetime.date.today()
detail['date'] = today
self.user_details.append(detail)
def get_details(self):
return self.user_details
def make_messages(self):
if len(self.user_details) > 0:
for detail in self.get_details():
name = detail["name"]
amount = detail["amount"]
date = detail["date"]
message = self.base_message
new_msg = message.format(
name=name,
date=date,
total=amount
)
self.messages.append(new_msg)
return self.messages
return[]
obj = MessageUser()
obj.add_user("Playstation", 230000)
print(obj.add_user())
`
I have a question , I can't install the module requests_html on MacOS Catalina ,
and have errors as follows , Can you help me ?
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
Perhaps try: xcode-select --install
*********************************************************************************
error: command '/usr/bin/clang' failed with exit code 71
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for lxml
Failed to build lxml
ERROR: Could not build wheels for lxml, which is required to install pyproject.toml-based projects
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.