Professional Documents
Culture Documents
Presented By,
Kavya HV
Asst Professor
Dept. of MCA
PESITM
1. Price Monitoring
2. Market Research:
3. News Monitoring:
Making a Request:
Kavya HV, Dept. of MCA, PESITM, Shimoga Page 5
Data Analytics using Python Module IV
Example:
import requests
# Specify the URL we want to make a GET request to
response = requests.get('https://www.w3schools.com')
# Check if the request was successful (status code 200)
if response.status_code == 200:
# Print the content of the response
print("Response content:")
print(response.content)
else:
print(f"Error: {response.status_code}")
Output:
Kavya HV, Dept. of MCA, PESITM, Shimoga Page 7
Data Analytics using Python Module IV
BeautifulSoup Library:
To import:
Submitting a form:
Steps for submitting form:
import time
driver = webdriver.chrome()
driver.maximize_window()
driver.get('https://the-internet.herokuapp.com/login')
driver.find_element(By.ID,"input-username").submit()
driver.find_element(By.ID,"input-password").submit()
username.send_keys('Ruthvi')
password.send_keys('Ruthvi@798')
submit.click()
import creds
loginurl=('https://the-
internet.herokuapp.com/authenticate')
secure_url=('https://the-internet.herokuapp.com/secure')
payload = {
'username': creds.username,
'password': creds.password
with requests.session() as s:
s.post(loginurl, data=payload)
r = s.get(secure_url)
print(soup.prettify())
driver = webdriver.Chrome()
driver.maximize_window()
time.sleep(3)
# Navigate to the form page
driver.get('https://the-internet.herokuapp.com/login')
# Locate form elements
pnr_field = driver.find_element("username",
"password")
submit_button =
driver.find_element(By.CSS_SELECTOR, '.col-xs-4')
# Fill in form fields
pnr_field.send_keys('Ruthvi', 'Ruthvi@798')
# Submit the form
submit_button.click()
welcome_message =
driver.find_element(By.CSS_SELECTOR,".pnr_field")
# Print or use the scraped values
print(type(welcome_message))
html_content =
welcome_message.get_attribute('outerHTML')
driver.quit()
Kavya HV, Dept. of MCA, PESITM, Shimoga Page 13
Data Analytics using Python Module IV
Introduction to NumPy:
• NumPy is a Python library used for working with
arrays.
• It also has functions for working in domain of linear
algebra, Fourier transform, and matrices.
• NumPy was created in 2005 by Travis Oliphant. It is
an open source project and we can use it freely.
• NumPy stands for Numerical Python.
• In Python we have lists that serve the purpose of
arrays, but they are slow to process.
• NumPy aims to provide an array object that is up to
50x faster than traditional Python lists.
• The array object in NumPy is called ndarray, it
provides a lot of supporting functions that make
working with ndarray very easy.
To import NumPy:
import numpy as np
Indexing of Arrays:
Slicing of Arrays:
Concatenation of Arrays:
Splitting of Arrays: