Ранее я делал серию постов про битовые операторы.
Вот вам ещё один наглядный пример как это используется в Python в модуле re.
Чтобы указать флаг для компилятора нам надо указать его после передаваемой строки. Например, добавляем флаг для игнорирования переноса строки.
pattern = re.compile(r"(\w+)+")
words = pattern.search(text, re.DOTALL)
А как указать несколько флагов? Ведь явно будут ситуации когда нам потребуется больше одного. Кто читал посты по битовые операторы уже понял как.
pattern.search(text, re.DOTALL | re.VERBOSE)
А теперь смотрим исходники, что находится в этих атрибутах?
Не удивительно, степени двойки. Почему? Потому что каждое следующее значение это сдвиг единицы влево.
>>> for n in [1, 2, 4, 8, 16, 32, 64, 128, 256]:
>>>
print(bin(n))
0b1
0b10
0b100
0b1000
0b10000
0b100000
0b1000000
0b10000000
0b100000000
Чтобы было понятней, давайте напишем тоже самое но иначе, добавим ведущие нули:
000000001
000000010
000000100
000001000
000010000
000100000
001000000
010000000
100000000
Не понятно что тут происходит? Читай три поста про битовые операторы начиная с этого ➡️https://t.me/pythonotes/45
В общем, это пример применения побитовых операций в самом Python.
Теперь вы знаете Python еще немного лучше)
#tricks#regex#libs
#other#playwright
Playwright CLI is a simple command-line tool for browser automation that works best with coding agents like Claude or GitHub Copilot. Install it globally with `npm install -g @playwright/cli@latest`, then use commands like `open`, `type`, `click`, `screenshot` to control browsers efficiently without loading heavy page data. It saves tokens for faster AI tasks on large codebases. You benefit by automating web tests, taking screenshots, and managing sessions quickly, making your coding and testing workflows smoother and more reliable.
https://github.com/microsoft/playwright-cli
#typescript#fingerprinting#playwright#puppeteer#scraping#typescript
Fingerprint-suite is a toolkit that generates and injects realistic browser fingerprints into automated browsers like Playwright and Puppeteer. It includes four modular packages: header-generator for HTTP headers, fingerprint-generator for browser fingerprints, fingerprint-injector for injection, and a Bayesian network for realistic fingerprint creation. Since websites increasingly use fingerprinting to track and identify users, this tool helps your web scrapers avoid detection by mimicking real browser behavior. You can customize fingerprints by device type and operating system, making your automated browsing appear completely legitimate to anti-bot systems.
https://github.com/apify/fingerprint-suite
#typescript#agent#ai#ai_agents#ai_tools#automation#browser#browser_automation#browser_use#chrome_extension#comet#dia#extension#manus#mariner#multi_agent#n8n#nano#opensource#playwright#web_automation
Nanobrowser is a free, open-source Chrome extension that uses multiple AI agents to automate complex web tasks directly in your browser, keeping your data private since everything runs locally. It supports many AI language models, lets you customize which models handle different tasks, and offers an easy chat interface to control and track automation. You can automate repetitive tasks, ask follow-up questions, and review past interactions without coding. It works best on Chrome and Edge and is a cost-effective alternative to expensive AI automation tools, giving you powerful, flexible web automation with full control and privacy.
https://github.com/nanobrowser/nanobrowser
#python#ai#ai_scraping#automation#crawler#crawling#crawling_python#data#data_extraction#mcp#mcp_server#playwright#python#scraping#selectors#stealth#web_scraper#web_scraping#web_scraping_python#webscraping#xpath
Scrapling is a fast Python web scraping tool that fetches pages, bypasses anti-bot blocks like Cloudflare, and adapts to site changes by auto-finding elements. Use simple CSS/XPath selectors, spiders for big crawls with pause/resume, proxy rotation, and CLI—no code needed sometimes. Install via pip; it's memory-light and beats others in speed. You save time fixing broken scrapers, scrape reliably at scale, cut costs with AI tools, and focus on using data for leads, prices, or research.
https://github.com/D4Vinci/Scrapling