import requests
from bs4 import BeautifulSoup
url = 'https://www.pythonforengineers.in/'
reqs = requests.get(url)
soup = BeautifulSoup(reqs.text, 'html.parser')
urls = []
for link in soup.find_all('a'):
print(link.get('href'))
Solve Problems by Coding Solutions - A Complete solution for python programming
import requests
from bs4 import BeautifulSoup
url = 'https://www.pythonforengineers.in/'
reqs = requests.get(url)
soup = BeautifulSoup(reqs.text, 'html.parser')
urls = []
for link in soup.find_all('a'):
print(link.get('href'))
import requests
from bs4 import BeautifulSoup
def getdata(url):
r = requests.get(url)
return r.text
htmldata = getdata("https://barcindia.co.in/data-insights")
soup = BeautifulSoup(htmldata, 'html.parser')
data = ''
for i in soup.find_all('tbody'):
data = data + (i.get_text())
data
data = ''.join((filter(lambda i: i not in ['\t'], data)))
print(data)
import requests
import pandas as pd
from bs4 import BeautifulSoup
def getdata(url):
r=requests.get(url)
return r.text
# Enter your own API key
api = 'YOUR API KEY'
number = '9876543210'
country = 'IN'
# pass Your API, number and country code
htmldata=getdata('http://apilayer.net/api/validate?access_key='+api+'&number='+number+'&country_code='+country+'&format=1')
soup = BeautifulSoup(htmldata, 'html.parser')
print(soup)
import time
import datetime as dt
import turtle
t = turtle.Turtle()
t1 = turtle.Turtle()
s = turtle.Screen()
s.bgcolor("green")
sec = dt.datetime.now().second
min = dt.datetime.now().minute
hr = dt.datetime.now().hour
t1.pensize(3)
t1.color('black')
t1.penup()
t1.goto(-20, 0)
t1.pendown()
for i in range(2):
t1.forward(200)
t1.left(90)
t1.forward(70)
t1.left(90)
t1.hideturtle()
while True:
t.hideturtle()
t.clear()
t.write(str(hr).zfill(2)
+ ":"+str(min).zfill(2)+":"
+ str(sec).zfill(2),
font=("Arial Narrow", 35, "bold"))
time.sleep(1)
sec += 1
if sec == 60:
sec = 0
min += 1
if min == 60:
min = 0
hr += 1
if hr == 13:
hr = 1
import openai
openai.api_key = "your secret api key"
while True:
model_engine = "text-davinci-003"
prompt = input('Enter new prompt: ')
if 'exit' in prompt or 'quit' in prompt:
break
completion = openai.Completion.create(
engine=model_engine,
prompt=prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
response = completion.choices[0].text
print(response)
To get secret api key go to openai.com/api/ and signup
then login and go to platform.openai.com/
click on personal and then click on vie api keys and now click on 'create new secret key'.