π₯ Trending Repository: pytorch
π Description: Tensors and Dynamic neural networks in Python with strong GPU acceleration
π Repository URL: https://github.com/pytorch/pytorch
π Website: https://pytorch.org
π Readme: https://github.com/pytorch/pytorch#readme
π Statistics:
π Stars: 94.5K stars
π Watchers: 1.8k
π΄ Forks: 25.8K forks
π» Programming Languages: Python - C++ - Cuda - C - Objective-C++ - CMake
π·οΈ Related Topics:
==================================
π§ By: https://t.me/DataScienceM
π Description: Tensors and Dynamic neural networks in Python with strong GPU acceleration
π Repository URL: https://github.com/pytorch/pytorch
π Website: https://pytorch.org
π Readme: https://github.com/pytorch/pytorch#readme
π Statistics:
π Stars: 94.5K stars
π Watchers: 1.8k
π΄ Forks: 25.8K forks
π» Programming Languages: Python - C++ - Cuda - C - Objective-C++ - CMake
π·οΈ Related Topics:
#python #machine_learning #deep_learning #neural_network #gpu #numpy #autograd #tensor
==================================
π§ By: https://t.me/DataScienceM
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "myDynamicElement"))
)
β’ Get the page source after JavaScript has executed.
dynamic_html = driver.page_source
β’ Close the browser window.
driver.quit()
VII. Common Tasks & Best Practices
β’ Handle pagination by finding the "Next" link.
next_page_url = soup.find('a', text='Next')['href']β’ Save data to a CSV file.
import csv
with open('data.csv', 'w', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
writer.writerow(['Title', 'Link'])
# writer.writerow([title, url]) in a loop
β’ Save data to CSV using
pandas.import pandas as pd
df = pd.DataFrame(data, columns=['Title', 'Link'])
df.to_csv('data.csv', index=False)
β’ Use a proxy with
requests.proxies = {'http': 'http://10.10.1.10:3128', 'https': 'http://10.10.1.10:1080'}
requests.get('http://example.com', proxies=proxies)β’ Pause between requests to be polite.
import time
time.sleep(2) # Pause for 2 seconds
β’ Handle JSON data from an API.
json_response = requests.get('https://api.example.com/data').json()β’ Download a file (like an image).
img_url = 'http://example.com/image.jpg'
img_data = requests.get(img_url).content
with open('image.jpg', 'wb') as handler:
handler.write(img_data)
β’ Parse a
sitemap.xml to find all URLs.# Get the sitemap.xml file and parse it like any other XML/HTML to extract <loc> tags.
VIII. Advanced Frameworks (
Scrapy)β’ Create a Scrapy spider (conceptual command).
scrapy genspider example example.com
β’ Define a
parse method to process the response.# In your spider class:
def parse(self, response):
# parsing logic here
pass
β’ Extract data using Scrapy's CSS selectors.
titles = response.css('h1::text').getall()β’ Extract data using Scrapy's XPath selectors.
links = response.xpath('//a/@href').getall()β’ Yield a dictionary of scraped data.
yield {'title': response.css('title::text').get()}β’ Follow a link to parse the next page.
next_page = response.css('li.next a::attr(href)').get()
if next_page is not None:
yield response.follow(next_page, callback=self.parse)β’ Run a spider from the command line.
scrapy crawl example -o output.json
β’ Pass arguments to a spider.
scrapy crawl example -a category=books
β’ Create a Scrapy Item for structured data.
import scrapy
class ProductItem(scrapy.Item):
name = scrapy.Field()
price = scrapy.Field()
β’ Use an Item Loader to populate Items.
from scrapy.loader import ItemLoader
loader = ItemLoader(item=ProductItem(), response=response)
loader.add_css('name', 'h1.product-name::text')
#Python #WebScraping #BeautifulSoup #Selenium #Requests
βββββββββββββββ
By: @DataScienceN β¨
β€3
π₯ Trending Repository: localstack
π Description: π» A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline
π Repository URL: https://github.com/localstack/localstack
π Website: https://localstack.cloud
π Readme: https://github.com/localstack/localstack#readme
π Statistics:
π Stars: 61.1K stars
π Watchers: 514
π΄ Forks: 4.3K forks
π» Programming Languages: Python - Shell - Makefile - ANTLR - JavaScript - Java
π·οΈ Related Topics:
==================================
π§ By: https://t.me/DataScienceM
π Description: π» A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline
π Repository URL: https://github.com/localstack/localstack
π Website: https://localstack.cloud
π Readme: https://github.com/localstack/localstack#readme
π Statistics:
π Stars: 61.1K stars
π Watchers: 514
π΄ Forks: 4.3K forks
π» Programming Languages: Python - Shell - Makefile - ANTLR - JavaScript - Java
π·οΈ Related Topics:
#python #testing #aws #cloud #continuous_integration #developer_tools #localstack
==================================
π§ By: https://t.me/DataScienceM