Python Codes Basic to Advance
2.66K subscribers
82 photos
5 videos
8 files
100 links
Python Codes Basic to Advance

All Codes
@C_Codes_pro
@CPP_Codes_pro
@Java_Codes_Pro
@nodejs_codes_pro

Discussion
@bca_mca_btech
Download Telegram
Forwarded from ˹ᴍʀ sᴜᴋᴋᴜɴ˼ (Mukesh test bot)
This media is not supported in your browser
VIEW IN TELEGRAM
👩‍💻 Wᴇʟᴄᴏᴍᴇ ᴛᴏ @CodesSnippet! 🚀

Jᴏɪɴ ᴜs ғᴏʀ ᴅᴀɪʟʏ sɴɪᴘᴘᴇᴛs ᴏғ ᴄᴏᴅɪɴɢ 🧩 ᴋɴᴏᴡʟᴇᴅɢᴇ! 💻💡

Hᴇʀᴇ, ʏᴏᴜ'ʟʟ ғɪɴᴅ 👀 ʙɪᴛᴇ-sɪᴢᴇᴅ ᴘɪᴇᴄᴇs ᴏғ ᴄᴏᴅᴇ, 🔥 ᴘʀᴏɢʀᴀᴍᴍɪɴɢ ᴛɪᴘs, ᴀɴᴅ ᴛʀɪᴄᴋs ᴛᴏ ʟᴇᴠᴇʟ ᴜᴘ ʏᴏᴜʀ ᴄᴏᴅɪɴɢ sᴋɪʟʟs! 💪💻

Sᴛᴀʏ ᴜᴘᴅᴀᴛᴇᴅ ᴏɴ ᴛʜᴇ ʟᴀᴛᴇsᴛ ᴛʀᴇɴᴅs ɪɴ ᴛʜᴇ ᴛᴇᴄʜ ᴡᴏʀʟᴅ ᴀɴᴅ ᴇɴɢᴀɢᴇ ᴡɪᴛʜ ғᴇʟʟᴏᴡ ᴄᴏᴅᴇʀs 🤝 ɪɴ ᴏᴜʀ ᴠɪʙʀᴀɴᴛ ᴄᴏᴍᴍᴜɴɪᴛʏ! 🌐💬

Lᴇᴛ's ᴄʀᴀᴄᴋ ᴛʜᴇ ᴄᴏᴅɪɴɢ 🚪 ᴛᴏɢᴇᴛʜᴇʀ ᴀɴᴅ ʙʀɪɴɢ ʏᴏᴜʀ ᴘʀᴏJᴇᴄᴛs ᴛᴏ ʟɪғᴇ!
#CodeSnippet
#ProgrammingFun

Jᴏɪɴ ᴜs :- @CodesSnippet
1
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"))


#CodeSnippet
#ProgrammingFun

Language: Python

Join :- @Python_Codes_Pro

Support group :- @python_group_pro
Forwarded from ˹ᴍʀ sᴜᴋᴋᴜɴ˼ (Mᴜᴋᴇsʜ)
Search hd image from unsplash using mukesh api

import requests

ask = input("query to search image:- ")

class Unsplash:
base_url = "https://mukesh-api.vercel.app/"
"""search image from unsplash api by @mr_sukkun"""

def __init__(self, ask) -> None:
self.ask = ask

def unsplash_reply(self):
url = f"{self.base_url}unsplash?query={self.ask}"
response = requests.get(url)
if response.status_code == 200:
return response.json()
else:
return {"error": "Failed to fetch data"}

x = Unsplash(ask)
print(x.unsplash_reply())



#CodeSnippet
#ProgrammingFun

Language: Python
Jᴏɪɴ ᴜs :- @CodesSnippet
2
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', ...']

#CodeSnippet
#ProgrammingFun

Language: Python
Join :- @Python_Codes_Pro

Support group :- @python_group_pro
1👍1👏1
Exclusion from the queue

The collections.deque() class is a generalization of stacks and queues, and represents a deque. A deque() supports thread-safe, memory-efficient operations for inserting and removing elements of a sequence from either side, with roughly the same O(1) performance in either direction.
#CodeSnippet
#ProgrammingFun
#python3
#python
⭐️Add coding folder 👇
https://t.me/addlist/2UhsQW_cGzkxMzg1
1👍1