Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Google Colab Use Google Colab and do the following tasks Rename your Notebook tohw10.ipynb Mount Google Drive (!curlipecho.net/plain #ipaddress ! echo '' fromgoogle.colabimportdrive drive.mount( '/content/gdrive'

Google Colab

Use Google Colab and do the following tasks

Rename your Notebook tohw10.ipynb

Mount Google Drive (!curlipecho.net/plain#ipaddress !echo'' fromgoogle.colabimportdrive drive.mount('/content/gdrive')#mountgoogledrive !curlhttps://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh--outputanaconda.sh#downloadanaconda3.8 !bashanaconda.sh-b-p/root/anaconda3-f>/dev/null2>&1#installanaconda3silently ! ~/anaconda3/bin/pythongdrive/MyDrive/tmp/exercise1.py#executesomepythonfile ! cd gdrive/MyDrive/tmp && ~/anaconda3/bin/pythonexercise1.py#analternativewaytoexecutesomepythonfile(changedirectoryfirst,thenuserelativepath) 

Create a folder in Google Drive usingcommand linesin Colab.

oThe path to mounted Google Drive should be/content/gdrive/MyDrive/

oThe folder name isHW10

Download Anaconda 3.8

  • Modify the following code

( import requests

  • from bs4 import BeautifulSoup
  • import csv
  • # initialize http headers
  • headers = {
  • 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.72 Safari/537.36'
  • }
  • # send get request to target url using specified headers
  • response = requests.get('https://phys.org/technology-news/', headers=headers)
  • # get html text from http GET request
  • html = response.text
  • # create BeautifulSoup soup object named soup
  • soup = BeautifulSoup(html, 'html.parser')
  • # find in soup all article tags with specified class attribute
  • articles = soup.find_all('article', {'class': 'sorted-article'})
  • # initialize list to store article data
  • data = []
  • # loop through each article in articles
  • for article in articles:
  • # get title
  • title = article.find('a', {'class':'news-link'}).text
  • # get link to article
  • link = article.find('a', {'class':'news-link'}).get('href')
  • # get sub-category
  • subcat = article.find('div', {'class': 'text-low text-uppercase'}).text.strip()
  • # get relative time
  • reltime = articles[0].find_all('p', {'class': 'text-uppercase text-low'})[0].text.strip()
  • # get comment count
  • comments = articles[0].find_all('p', {'class': 'text-uppercase text-low'})[1].text.strip()
  • # get forward count
  • forwards = articles[0].find_all('p', {'class': 'text-uppercase text-low'})[2].text.strip()
  • # append article info to data list
  • data.append([title, link, subcat, reltime, comments, forwards])
  • # open csv file to write data
  • with open('tech_news.csv', 'w') as file:
  • # create csv writer object
  • writer = csv.writer(file)
  • # write header row
  • writer.writerow(['title', 'url', 'subcategory', 'time', 'comments', 'forwards'])
  • # write the data rows
  • writer.writerows(data) )

code and upload it to the newly created folder inweb browser

oThe output filepath (CSV file) should be customized for Colab in theHW10folder

Execute the modified code with Anaconda 3.8 usingcommand lines

Note: the `command lines` in the requirements refer to the Ubuntu Terminal commands after ! in Notebook

Submission

Submit thehw10.ipynbin `Colab Notebooks` in your Google Drive to Canvas

Submit the link to the newly created folder,HW10. In this folder, it should contain

oThe modified program

oThe CSV file generated by this file

oFor sharing the folder on Google Drive, set `Anyone with the link`

Make sure your URL works in incognito mode

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

=+What does ML mean?

Answered: 1 week ago

Question

Discuss the problems NATs create for IPsec security.

Answered: 1 week ago

Question

1. How do most insects respire ?

Answered: 1 week ago

Question

Who is known as the father of the indian constitution?

Answered: 1 week ago

Question

1.explain evaporation ?

Answered: 1 week ago