Forwarded from Machine Learning with Python
Beautiful Soup — a library for extracting data from HTML and XML files, ideal for web scraping.
pip install beautifulsoup4
from bs4 import BeautifulSoup
import requests
html_doc = "<html><body><p class='text'>Hello, world!</p></body></html>"
soup = BeautifulSoup(html_doc, 'html.parser') # or 'lxml', 'html5lib'
print(soup.p.text) # Hello, world!
# First found element
first_p = soup.find('p')
# Search by class or attribute
text_elem = soup.find('p', class_='text')
text_elem = soup.find('p', {'class': 'text'})
# All elements
all_p = soup.find_all('p')
all_text_class = soup.find_all(class_='text')
a_tag = soup.find('a')
print(a_tag['href']) # value of the href attribute
print(a_tag.get_text()) # text inside the tag
print(a_tag.text) # alternative# Moving to parent, children, siblings
parent = soup.p.parent
children = soup.ul.children
next_sibling = soup.p.next_sibling
# Finding the previous/next element
prev_elem = soup.find_previous('p')
next_elem = soup.find_next('div')
response = requests.get('https://example.com')
soup = BeautifulSoup(response.text, 'html. parser')
noscript = soup.noscript.text
links = [a['href'] for a in soup.find_all('a', href=True)]# More powerful and concise search
items = soup.select('div.content > p.text')
first_item = soup.select_one('a.button')
🟢 Web scraping and data collection🟢 Processing HTML/XML reports🟢 Automating data extraction from websites🟢 Preparing data for analysis and machine learning
Please open Telegram to view this post
VIEW IN TELEGRAM
❤8🥰1
What is a closure?
Answer:
How does a closure work?
This is useful when you need to pass a state or data without using global variables.
tags: #interview
Please open Telegram to view this post
VIEW IN TELEGRAM
❤4
For example,
GET is used to retrieve data, POST — to create new records, and DELETE — to delete.In the picture — the 9 most popular HTTP request methods that every developer should have at hand.
Save it so you don't forget!
Please open Telegram to view this post
VIEW IN TELEGRAM
❤2
🙏💸 500$ FOR THE FIRST 500 WHO JOIN THE CHANNEL! 🙏💸
Join our channel today for free! Tomorrow it will cost 500$!
https://news.1rj.ru/str/+0-w7MQwkOs02MmJi
You can join at this link! 👆👇
https://news.1rj.ru/str/+0-w7MQwkOs02MmJi
Join our channel today for free! Tomorrow it will cost 500$!
https://news.1rj.ru/str/+0-w7MQwkOs02MmJi
You can join at this link! 👆👇
https://news.1rj.ru/str/+0-w7MQwkOs02MmJi
What is
monkey patching?Answer:
tags: #interview
Please open Telegram to view this post
VIEW IN TELEGRAM
❤4
Python Clean Code: Stop Writing Bad Code — Lessons from Uncle Bob
Are you tired of writing messy and unorganized code that leads to frustration and bugs? You can transform your code from a confusing mess into something crystal clear with a few simple changes. In this article, we'll explore key principles from the book "Clean Code" by Robert C. Martin, also known as Uncle Bob, and apply them to Python. Whether you're a web developer, software engineer, data analyst, or data scientist, these principles will help you write clean, readable, and maintainable Python code.
Read: https://habr.com/en/articles/841820/
https://news.1rj.ru/str/CodeProgrammer🧠
Are you tired of writing messy and unorganized code that leads to frustration and bugs? You can transform your code from a confusing mess into something crystal clear with a few simple changes. In this article, we'll explore key principles from the book "Clean Code" by Robert C. Martin, also known as Uncle Bob, and apply them to Python. Whether you're a web developer, software engineer, data analyst, or data scientist, these principles will help you write clean, readable, and maintainable Python code.
Read: https://habr.com/en/articles/841820/
https://news.1rj.ru/str/CodeProgrammer
Please open Telegram to view this post
VIEW IN TELEGRAM
❤3
Integrating Local LLMs with Ollama and Python 🤖💻
Did you know that integrating local large language models (LLMs) into your Python projects can help improve privacy, reduce costs, and build offline-capable AI-powered apps? 👉
To get started, follow these steps:
• Set up Ollama and pull the models you want to use.
• Connect to them from Python using the <code>ollama</code> library.
Watch this video on how to integrate OLLAMA into your python projects https://youtu.be/E4l91XKQSgw?si=3gaeoM3EbvO6QYIC
Key Benefits:
• Improved privacy
• Reduced costs
• Offline-capable AI-powered apps
Did you know that integrating local large language models (LLMs) into your Python projects can help improve privacy, reduce costs, and build offline-capable AI-powered apps? 👉
To get started, follow these steps:
• Set up Ollama and pull the models you want to use.
• Connect to them from Python using the <code>ollama</code> library.
Watch this video on how to integrate OLLAMA into your python projects https://youtu.be/E4l91XKQSgw?si=3gaeoM3EbvO6QYIC
Key Benefits:
• Improved privacy
• Reduced costs
• Offline-capable AI-powered apps
YouTube
How to Build a Local AI Agent With Python (Ollama, LangChain & RAG)
Thanks to Microsoft for sponsoring this video! Submit your #CodingWithCopilot stories so I can review them! I'm excited to check out more!
Today I'll be showing you how to build local AI agents using Python. We'll be using Ollama, LangChain, and something…
Today I'll be showing you how to build local AI agents using Python. We'll be using Ollama, LangChain, and something…
❤1
Uv vs Pip: Choosing the Right Package Manager for Your Python Projects 👉
When it comes to choosing a package manager for your Python projects, you have two popular options: uv and pip. While both tools share many similarities, there are key differences that may sway your decision.
* pip: Great for out-of-the-box availability, broad compatibility, and reliable ecosystem support. It's perfect for new projects or when you need to install popular packages quickly.
* uv: Worth considering if you prioritize fast installs, reproducible environments, and clean uninstall behavior. uv is ideal for streamline workflows for new projects, and its custom installation process can be beneficial for large-scale applications.
Here's a quick summary of the key differences:
* Package Installation: 📦
* pip: Easy to install popular packages using pip.
* uv: Requires manual package management, but can lead to faster installs and more reproducible environments.
* Dependency Management: 💻
* pip: Provides automatic dependency resolution for most projects.
* uv: Requires custom dependency management, which can be beneficial for complex projects.
By considering these factors and comparing the two tools, you'll make an informed decision that suits your specific needs.
When it comes to choosing a package manager for your Python projects, you have two popular options: uv and pip. While both tools share many similarities, there are key differences that may sway your decision.
* pip: Great for out-of-the-box availability, broad compatibility, and reliable ecosystem support. It's perfect for new projects or when you need to install popular packages quickly.
* uv: Worth considering if you prioritize fast installs, reproducible environments, and clean uninstall behavior. uv is ideal for streamline workflows for new projects, and its custom installation process can be beneficial for large-scale applications.
Here's a quick summary of the key differences:
* Package Installation: 📦
* pip: Easy to install popular packages using pip.
* uv: Requires manual package management, but can lead to faster installs and more reproducible environments.
* Dependency Management: 💻
* pip: Provides automatic dependency resolution for most projects.
* uv: Requires custom dependency management, which can be beneficial for complex projects.
By considering these factors and comparing the two tools, you'll make an informed decision that suits your specific needs.
❤2
🚀 Lightweight X11 App Launcher for Python 🎉
X11 app launchers are powerful tools that can greatly enhance your Python development experience. However, creating a custom launcher from scratch can be challenging and time-consuming.
Here's why:
* Performance: Creating a native X11 application requires a deep understanding of C, X11, and the underlying operating system.
* Portability: Building a cross-platform application can be difficult due to the varying differences between platforms.
* Customizability: Custom launchers require a good grasp of the underlying architecture and configuration options.
On the other hand, you can use existing libraries like
In this example, we'll create a simple launcher using
### Example Code
### Features
* Native X11 Application: This launcher uses the native X11 API to create a seamless desktop experience.
* Easy-to-Use Interface: The
### Benefits
* High Performance: The native X11 application ensures optimal performance and responsiveness.
* Cross-Platform Compatibility: This launcher is designed to be cross-platform, making it suitable for deployment on various operating systems.
By using
X11 app launchers are powerful tools that can greatly enhance your Python development experience. However, creating a custom launcher from scratch can be challenging and time-consuming.
Here's why:
* Performance: Creating a native X11 application requires a deep understanding of C, X11, and the underlying operating system.
* Portability: Building a cross-platform application can be difficult due to the varying differences between platforms.
* Customizability: Custom launchers require a good grasp of the underlying architecture and configuration options.
On the other hand, you can use existing libraries like
pywinauto or pyppeteer to create a lightweight X11 app launcher for Python.In this example, we'll create a simple launcher using
pywinauto, which provides an easy-to-use API for automating desktop applications.### Example Code
import pywinauto
def launch_app():
# Create the main window
app = pywinauto.application().start('MyApp')
# Launch the main menu
menu = app.top_menu()
menu.show()
# Start the application
launch_app()
### Features
* Native X11 Application: This launcher uses the native X11 API to create a seamless desktop experience.
* Easy-to-Use Interface: The
pywinauto library provides an intuitive API, making it easy to customize and extend the launcher.### Benefits
* High Performance: The native X11 application ensures optimal performance and responsiveness.
* Cross-Platform Compatibility: This launcher is designed to be cross-platform, making it suitable for deployment on various operating systems.
By using
pywinauto to create a lightweight X11 app launcher for Python, you can take advantage of the power of C and X11 while still enjoying a seamless desktop experience. Give this example a try and see how it can enhance your Python development workflow!❤2
How to sort a list of dictionaries by a specific field?
Answer:
This parameter passes a function that extracts the value of the desired field from each dictionary. The .sort() method modifies the list in place, while sorted() returns a new sorted list.
tags: #interview
Please open Telegram to view this post
VIEW IN TELEGRAM
❤1
Media is too big
VIEW IN TELEGRAM
Ant AI Automated Sales Robot is an intelligent robot focused on automating lead generation and sales conversion. Its core function simulates human conversation, achieving end-to-end business conversion and easily generating revenue without requiring significant time investment.
I. Core Functions: Fully Automated "Lead Generation - Interaction - Conversion"
Precise Lead Generation and Human-like Communication: Ant AI is trained on over 20 million real social chat records, enabling it to autonomously identify target customers and build trust through natural conversation, requiring no human intervention.
High Conversion Rate Across Multiple Scenarios: Ant AI intelligently recommends high-conversion-rate products based on chat content, guiding customers to complete purchases through platforms such as iFood, Shopee, and Amazon. It also supports other transaction scenarios such as movie ticket purchases and utility bill payments.
24/7 Operation: Ant AI continuously searches for customers and recommends products. You only need to monitor progress via your mobile phone, requiring no additional management time.
II. Your Profit Guarantee: Low Risk, High Transparency, Zero Inventory Pressure, Stable Commission Sharing
We have established partnerships with platforms such as Shopee and Amazon, which directly provide abundant product sourcing. You don't need to worry about inventory or logistics. After each successful order, the company will charge the merchant a commission and share all profits with you. Earnings are predictable and withdrawals are convenient. Member data shows that each bot can generate $30 to $100 in profit per day. Commission income can be withdrawn to your account at any time, and the settlement process is transparent and open.
Low Initial Investment Risk. Bot development and testing incur significant costs. While rental fees are required, in the early stages of the project, the company prioritizes market expansion and brand awareness over short-term profits.
If you are interested, please join my Telegram group for more information and leave a message: https://news.1rj.ru/str/+lVKtdaI5vcQ1ZDA1
I. Core Functions: Fully Automated "Lead Generation - Interaction - Conversion"
Precise Lead Generation and Human-like Communication: Ant AI is trained on over 20 million real social chat records, enabling it to autonomously identify target customers and build trust through natural conversation, requiring no human intervention.
High Conversion Rate Across Multiple Scenarios: Ant AI intelligently recommends high-conversion-rate products based on chat content, guiding customers to complete purchases through platforms such as iFood, Shopee, and Amazon. It also supports other transaction scenarios such as movie ticket purchases and utility bill payments.
24/7 Operation: Ant AI continuously searches for customers and recommends products. You only need to monitor progress via your mobile phone, requiring no additional management time.
II. Your Profit Guarantee: Low Risk, High Transparency, Zero Inventory Pressure, Stable Commission Sharing
We have established partnerships with platforms such as Shopee and Amazon, which directly provide abundant product sourcing. You don't need to worry about inventory or logistics. After each successful order, the company will charge the merchant a commission and share all profits with you. Earnings are predictable and withdrawals are convenient. Member data shows that each bot can generate $30 to $100 in profit per day. Commission income can be withdrawn to your account at any time, and the settlement process is transparent and open.
Low Initial Investment Risk. Bot development and testing incur significant costs. While rental fees are required, in the early stages of the project, the company prioritizes market expansion and brand awareness over short-term profits.
If you are interested, please join my Telegram group for more information and leave a message: https://news.1rj.ru/str/+lVKtdaI5vcQ1ZDA1
❤1
How to organize a message queue via Redis?
Answer:
A more reliable approach is Redis Streams, which support groups of consumers and message processing confirmation, which helps to avoid losses. Pub/Sub is usually not used for queues, as messages are not stored and can be lost.
tags: #interview
Please open Telegram to view this post
VIEW IN TELEGRAM
❤2
This project uses YOLOv8 for object detection, OpenCV for video processing, and custom-defined security zones to detect intrusions in restricted areas. When a person enters a defined zone, the system triggers an alert sound and automatically captures snapshots for evidence.
https://youtu.be/W2T2PgVIV3A?si=6Pf_c0veplMHIvDJ
https://youtu.be/W2T2PgVIV3A?si=6Pf_c0veplMHIvDJ
YouTube
Real-Time Intrusion Detection System Using YOLOv8 & OpenCV | Python Computer Vision
Build a real-time Intrusion Detection System using Python, OpenCV, and YOLOv8.
This project demonstrates AI-powered object detection with custom security zones and alert notifications.
In this video, I show how to create an intrusion detection system using…
This project demonstrates AI-powered object detection with custom security zones and alert notifications.
In this video, I show how to create an intrusion detection system using…
❤3
What are the list methods in Python?
• append() — adds an element to the end of the list
• pop() — removes the last element of the list (or the element at a given index)
• insert() — adds an element at any position in the list by index
• remove() — removes the first found element from the list by value
• map() — applies a function to each element and returns an iterator (can be converted to a list)
• filter() — selects elements that satisfy a condition and returns an iterator
• reduce() (from the functools module) — reduces the list to a single value by processing elements sequentially
@DataScienceQ
• pop() — removes the last element of the list (or the element at a given index)
• insert() — adds an element at any position in the list by index
• remove() — removes the first found element from the list by value
• map() — applies a function to each element and returns an iterator (can be converted to a list)
• filter() — selects elements that satisfy a condition and returns an iterator
• reduce() (from the functools module) — reduces the list to a single value by processing elements sequentially
@DataScienceQ
❤4
❗️LISA HELPS EVERYONE EARN MONEY!$29,000 HE'S GIVING AWAY TODAY!
Everyone can join his channel and make money! He gives away from $200 to $5.000 every day in his channel
https://news.1rj.ru/str/+HDFF3Mo_t68zNWQy
⚡️FREE ONLY FOR THE FIRST 500 SUBSCRIBERS! FURTHER ENTRY IS PAID! 👆👇
https://news.1rj.ru/str/+HDFF3Mo_t68zNWQy
Everyone can join his channel and make money! He gives away from $200 to $5.000 every day in his channel
https://news.1rj.ru/str/+HDFF3Mo_t68zNWQy
⚡️FREE ONLY FOR THE FIRST 500 SUBSCRIBERS! FURTHER ENTRY IS PAID! 👆👇
https://news.1rj.ru/str/+HDFF3Mo_t68zNWQy
When deploying and running Python code on cloud-based clusters using Ray, one specific technical detail to focus on is the use of
When applying the
Source: https://towardsdatascience.com/ray-distributed-computing-for-all-part-2/
ray.remote decorator.When applying the
@ray.remote decorator to your Python functions, ensure that each function takes a single argument (the object being acted upon) and returns a value. This allows Ray to properly serialize and de-serialize data for distributed computing. For example:import ray
@ray.remote
def my_function(x):
# do some computation on x
return result
Source: https://towardsdatascience.com/ray-distributed-computing-for-all-part-2/
Towards Data Science
Ray: Distributed Computing For All, Part 2 | Towards Data Science
Deploying and running Python code on cloud-based clusters
❤5
Why shouldn't you compare two
float values using "=="?Answer:
tags: #interview
Please open Telegram to view this post
VIEW IN TELEGRAM
❤2👍1
Forwarded from Machine Learning with Python
Learn Python with the University of Helsinki
✓ With an official certificate
✓ From zero to advanced level
✓ 14 parts with practical tasks
All content is available → here
https://programming-25.mooc.fi/
👉 @codeprogrammer
✓ With an official certificate
✓ From zero to advanced level
✓ 14 parts with practical tasks
All content is available → here
https://programming-25.mooc.fi/
Please open Telegram to view this post
VIEW IN TELEGRAM