Answer correct option for each question below What will be the output of the following…
- User
Answer correct option for each question below
What will be the output of the following code? x = (soup.find(class_='infobox-data').text) x[0:26] (Scraping directly from Mahatma Gandhi Ji’s Page)
‘Mohandas Karamchand Gandhi’
(1869-10-02)
Porbandar State
Error
In the code below: for i in range(10): print( '[ ' + str(i) + ' ] ' ) What will happen if we didn’t type casted ‘i’ as string?
It will work normally.
It will print [0,1,2,3,4,5,6,7,8,9]
It will [0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
Error
How can you extract image of Mahatma Gandhi? (Scraping directly from page)
print(soup.find('img').get('src'))
print(soup.find('table',class_ = 'infobox biography vcard').get('href'))
print(soup.find('a',class_ = 'image').get('href'))
print(soup.find(‘img’, class_ = ‘infobox biography vcard’).get(‘href’))
How to extract birth date of Mahatma Gandhi? (Scraping directly from page)
soup.find(‘span’,class_ = ‘bday’).text
soup.find(‘table’,class_ = ‘infobox-label’).get(‘bday’)
soup.find(‘table’ , class_ = ‘infobox biography vcard’).get(‘bday’)
None of the above.
What is the need of creating a link using google when we can directly copy the link manually?
To make the code look more tough.
To increase the complexity of code.
To make our code more dynamic in nature.
None
Can this code be used to create a link by which we can get to the persons Wikipedia page? inp = input(‘Enter Persons name’) link2 = “https://www.google.com/search?q=” + str(inp) +” ”+ “Wikipedia” link2= link2.replace(' ', '+')
True
False
To scrap the link of above Wikipedia page(M.K.Gandhi) from google can we use this code? soup.find_all(‘div’ , class_ = ‘yuRUbf’).get(‘href’).text
True
False
While scraping the link for a person why did we used try and except rather than just using .get(‘href’)?
Because all divs didn’t contained anchor tags.
Because it helped us to get 1 st page link.
Because it decreases the complexity of code.
None
Is it necessary to include the code if('en.wikipedia.org' in link3) or the try and except method would be able to scrap the link? (Google Wikipedia link scrapping using try and except)
Yes
No
Will this code work if we misspell a very famous person? (Google Wikipedia link scrapping using try and except)
- Assistant
Sure, here are the correct options for each question:
-
What will be the output of the following code?
x = (soup.find(class_='infobox-data').text) x[0:26]Correct Option:
‘Mohandas Karamchand Gandhi’ -
In the code below:
for i in range(10): print( '[ ' + str(i) + ' ] ' )
-