Python Projects & Free Books
37.6K subscribers
536 photos
93 files
282 links
Python Interview Projects & Free Courses

Admin: @Coderfun
Download Telegram
pip install PyPDF2
pip install pyttsx3


```python
import PyPDF2
import pyttsx3
# Read the pdf by specifying the path in your computer
pdfReader = PyPDF2.PdfFileReader(open('clcoding.pdf', 'rb'))
# Get the handle to speaker
speaker = pyttsx3.init()
# split the pages and read one by one
for page_num in range(pdfReader.numPages):
text = pdfReader.getPage(page_num).extractText()
speaker.say(text)
speaker.runAndWait()
# stop the speaker after completion
speaker.stop()
# save the audiobook at specified path
engine.save_to_file(text, 'E:\audio.mp3')
engine.runAndWait()`

🔅 Create an Audiobook in Python
👍57👎1
Large English learning resources collection
👇👇
https://t.me/englishlearnerspro/111
👍15
Scrap Image from google using BeautifulSoup
import requests
from bs4 import BeautifulSoup as BSP

def get_image_urls(search_query):
url = f"https://www.google.com/search?q={search_query}&tbm=isch"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
}
rss = requests.get(url, headers=headers)
soup = BSP(rss.content, "html.parser")

all_img = []
for img in soup.find_all('img'):
src = img['src']
if not src.endswith("gif"):
all_img.append(src)

return all_img

print(get_image_urls("boy"))
👍20
Scrap Image from bing using BeautifulSoup
import requests
from bs4 import BeautifulSoup as BSP

def split_url(url):
return url.split('&')[0]

def get_image_urls(search_query):
url = f"https://cn.bing.com/images/search?q={search_query}&first=1&cw=1177&ch=678"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
}
rss = requests.get(url, headers=headers)
soup = BSP(rss.content, "html.parser")

all_img = []
for img in soup.find_all('img'):
img_url = img.get('src2')
if img_url and img_url.startswith('https://tse2.mm.bing.net/'):
img_url = split_url(img_url)
all_img.append(img_url)

return all_img

print(get_image_urls("cat"))


sample response :
['https://tse2.mm.bing.net/th?q=Cat+Portrait', ...']
👍19
Tips to Merge two dictionary

boy={"ram":70,"Sundar":80}

girl={"riya":80,"Sonali":70}

student=boy | girl

print(student)
👍23