Skip to content

Commit a1c5c22

Browse files
Initial commit
0 parents  commit a1c5c22

24 files changed

+256
-0
lines changed

Default.sublime-commands

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[
2+
{
3+
"caption": "Python Web Scraping Snippets: Open Readme",
4+
"command": "open_file",
5+
"args": {
6+
"file": "${packages}/Python Web Scraping Snippets/README.md"
7+
}
8+
}
9+
]

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 futureprogrammer360
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# 🌐 Python Web Scraping Snippets
2+
3+
[![Downloads](https://img.shields.io/packagecontrol/dt/Python%20Web%20Scraping%20Snippets)](https://packagecontrol.io/packages/Python%20Web%20Scraping%20Snippets)
4+
[![Tag](https://img.shields.io/github/v/tag/futureprogrammer360/Python-Web-Scraping-Snippets?sort=semver)](https://github.com/futureprogrammer360/Python-Web-Scraping-Snippets/tags)
5+
[![Repo size](https://img.shields.io/github/repo-size/futureprogrammer360/Python-Web-Scraping-Snippets)](https://github.com/futureprogrammer360/Python-Web-Scraping-Snippets)
6+
[![License](https://img.shields.io/github/license/futureprogrammer360/Python-Web-Scraping-Snippets?style=flat-square)](https://github.com/futureprogrammer360/Python-Web-Scraping-Snippets/blob/master/LICENSE)
7+
8+
[Python Web Scraping Snippets](https://github.com/futureprogrammer360/Python-Web-Scraping-Snippets) is a collection of [Sublime Text](https://www.sublimetext.com/) snippets for web scraping and HTML parsing in Python.
9+
10+
## 💻 Installation
11+
12+
The easiest way to install Python Web Scraping Snippets is through [Package Control](https://packagecontrol.io/packages/Python%20Web%20Scraping%20Snippets). After it is enabled inside Sublime Text, open the command palette and find **Package Control: Install Package** and press `ENTER`. Then, find **Python Web Scraping Snippets** in the list. Press `ENTER` again, and this package is installed!
13+
14+
## 📈 Snippets
15+
16+
* [Imports](#imports)
17+
* [BeautifulSoup4](#beautifulsoup4)
18+
* [Requests](#requests)
19+
* [Requests-HTML](#requests-html)
20+
21+
### Imports
22+
23+
Import snippets start with `i` followed by the import alias.
24+
25+
| Trigger | Description |
26+
|---------------------|----------------------------------------------|
27+
| `ibs` | `from bs4 import BeautifulSoup` |
28+
| `irequests` | `import requests` |
29+
| `iAsyncHTMLSession` | `from requests_html import AsyncHTMLSession` |
30+
| `iHTMLSession` | `from requests_html import HTMLSession` |
31+
32+
### BeautifulSoup4
33+
34+
| Trigger | Description |
35+
|--------------|--------------------------------|
36+
| `bs` | `bs4.BeautifulSoup` |
37+
| `find` | `bs4.BeautifulSoup.find` |
38+
| `find_all` | `bs4.BeautifulSoup.find_all` |
39+
| `prettify` | `bs4.BeautifulSoup.prettify` |
40+
| `select` | `bs4.BeautifulSoup.select` |
41+
| `select_one` | `bs4.BeautifulSoup.select_one` |
42+
43+
### Requests
44+
45+
| Trigger | Description |
46+
|-----------|--------------------|
47+
| `delete` | `requests.delete` |
48+
| `get` | `requests.get` |
49+
| `head` | `requests.head` |
50+
| `patch` | `requests.patch` |
51+
| `post` | `requests.post` |
52+
| `put` | `requests.put` |
53+
| `request` | `requests.request` |
54+
55+
### Requests-HTML
56+
57+
| Trigger | Description |
58+
|--------------------|----------------------------------|
59+
| `AsyncHTMLSession` | `requests_html.AsyncHTMLSession` |
60+
| `HTMLSession` | `requests_html.HTMLSession` |
61+
62+
The snippet files are in the [`snippets`](https://github.com/futureprogrammer360/Python-Web-Scraping-Snippets/tree/master/snippets) folder of [this GitHub repository](https://github.com/futureprogrammer360/Python-Web-Scraping-Snippets).

messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"install": "messages/install.txt"
3+
}

messages/install.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Hello fellow web scraping lover!
2+
3+
Thank you for installing the Python Web Scraping Snippets package. This is a collection of useful snippets for web scraping in Python.
4+
5+
To see the snippets available, check out the README.md file via the `Python Web Scraping Snippets: Open Readme` command in command palette.
6+
7+
Enjoy!
8+
9+
GitHub homepage: https://github.com/futureprogrammer360/Python%20Web%20Scraping%20Snippets
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:soup} = BeautifulSoup(${2:response.content}, ${3:"html.parser"})
4+
]]></content>
5+
<tabTrigger>bs</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>bs4.BeautifulSoup</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:soup}.find($0)
4+
]]></content>
5+
<tabTrigger>find</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>bs4.BeautifulSoup.find</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:soup}.find_all($0)
4+
]]></content>
5+
<tabTrigger>find_all</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>bs4.BeautifulSoup.find_all</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:soup}.prettify($0)
4+
]]></content>
5+
<tabTrigger>prettify</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>bs4.BeautifulSoup.prettify</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:soup}.select($0)
4+
]]></content>
5+
<tabTrigger>select</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>bs4.BeautifulSoup.select</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:soup}.select_one($0)
4+
]]></content>
5+
<tabTrigger>select_one</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>bs4.BeautifulSoup.select_one</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
from requests_html import AsyncHTMLSession
4+
]]></content>
5+
<tabTrigger>iAsyncHTMLSession</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>from requests_html import AsyncHTMLSession</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
from requests_html import HTMLSession
4+
]]></content>
5+
<tabTrigger>iHTMLSession</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>from requests_html import HTMLSession</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
from bs4 import BeautifulSoup
4+
]]></content>
5+
<tabTrigger>ibs</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>from bs4 import BeautifulSoup</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
import requests
4+
]]></content>
5+
<tabTrigger>irequests</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>import requests</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:session} = AsyncHTMLSession()
4+
]]></content>
5+
<tabTrigger>AsyncHTMLSession</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>requests_html.AsyncHTMLSession</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:session} = HTMLSession()
4+
]]></content>
5+
<tabTrigger>HTMLSession</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>requests_html.HTMLSession</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:r} = requests.delete(${2:url})
4+
]]></content>
5+
<tabTrigger>delete</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>requests.delete</description>
8+
</snippet>

snippets/requests/get.sublime-snippet

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:r} = requests.get(${2:url})
4+
]]></content>
5+
<tabTrigger>get</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>requests.get</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:r} = requests.head(${2:url})
4+
]]></content>
5+
<tabTrigger>head</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>requests.head</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:r} = requests.patch(${2:url}, data=${3:data})
4+
]]></content>
5+
<tabTrigger>patch</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>requests.patch</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:r} = requests.post(${2:url}, data=${3:data})
4+
]]></content>
5+
<tabTrigger>post</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>requests.post</description>
8+
</snippet>

snippets/requests/put.sublime-snippet

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:r} = requests.put(${2:url}, data=${3:data})
4+
]]></content>
5+
<tabTrigger>put</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>requests.put</description>
8+
</snippet>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<snippet>
2+
<content><![CDATA[
3+
${1:r} = requests.request(${2:method}, ${3:url})
4+
]]></content>
5+
<tabTrigger>request</tabTrigger>
6+
<scope>source.python</scope>
7+
<description>requests.request</description>
8+
</snippet>

0 commit comments

Comments
 (0)