Skip to main content

Use Python to know about Artificial Intelligence

 Hey, welcome back! 

You'll be happy to know that you can use python to know about any topic related to your research from wikipedia.
python, know information using python, wikipedia, pythonbeginners, python learners, python coding, programming
Let's check the code.

    #import module
import requests
import pandas as pd
from bs4 import BeautifulSoup

def getdata(url):
    r=requests.get(url)
    return r.text
htmldata=getdata("https://en.wikipedia.org/wiki/Artificial_Intelligence")
soup= BeautifulSoup(htmldata, 'html.parser')
data=''
for data in soup.find_all("p"):
    print(data.get_text())

Here is the output of the code.

python, know information using python, wikipedia, pythonbeginners, python learners, python coding, programming



You can use the same code for acquiring various kind of information just by doing a slight change. 

htmldata=getdata("https://en.wikipedia.org/wiki/(#Entering the topic name")

Assume, you want to know about solar eclipse, here is the code for it. Observe the slight change in it.

#import module
import requests
import pandas as pd
from bs4 import BeautifulSoup

def getdata(url):
    r=requests.get(url)
    return r.text
htmldata=getdata("https://en.wikipedia.org/wiki/Solar_Eclipse")
soup= BeautifulSoup(htmldata, 'html.parser')
data=''
for data in soup.find_all("p"):
    print(data.get_text())
python, know information using python, wikipedia, pythonbeginners, python learners, python coding, programming

Similarly, you get information regarding any topic.
For doubts or feedback you can send us a mail or comment below.

Stay Tuned for more such posts!







Comments

Popular posts from this blog

Drawing Heart using python turtle!

  import   turtle def   curve ():      for   i   in   range ( 200 ):          turtle . right ( 1 )          turtle . forward ( 1 ) turtle . color ( "red" ) turtle . begin_fill () turtle . left ( 140 ) turtle . forward ( 111.65 ) curve () turtle . left ( 120 ) curve () turtle . forward ( 111.65 ) turtle . end_fill () turtle . hideturtle () turtle . done () Code reference: @pythongrowin

What is turtle.stamp() in python?

turtle.stamp() turtle.stamp() is used to stamp a copy of the turtle shape, it prints the shape at that point and moves forward with the instructions. Here shape of the turtle does not matter. It does the same for every turtle shape.  Example:  Here is the example of stamp() used: import   turtle def   tri ():      for   i   in   range ( 10 ):          turtle . degrees ( 60 )          turtle . forward ( 200 + 10 * i )          turtle . stamp ()          turtle . right ( 200 ) turtle . speed ( 7 ) turtle . color ( "orange" )         tri () turtle . done () For more such posts, stay tuned!