Skip to content

Commit 10ff2a5

Browse files
author
seospace
committed
sublime-snippets
1 parent 81cc6f6 commit 10ff2a5

123 files changed

Lines changed: 930 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ wheels/
2222
*.egg-info/
2323
.installed.cfg
2424
*.egg
25+
_other
26+
consumers/ser_base
2527

2628
# PyInstaller
2729
# Usually these files are written by a python script from a template

utils/extract_script_manual.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
from bs4 import BeautifulSoup as soup
2+
import requests
3+
import random
4+
5+
6+
SUBLIME_SNIPPET = """
7+
<snippet>
8+
<content><![CDATA[{0}${1}]]></content>
9+
<description> /{2}</description>
10+
<tabTrigger>{3}</tabTrigger>
11+
</snippet>
12+
13+
"""
14+
15+
TABLES = [
16+
dict(html_name='table sectionedit4', var_name="SETUP"), # The SETUP Section
17+
dict(html_name='table sectionedit6', var_name="STEP"), # The STEP Section
18+
dict(html_name='table sectionedit8', var_name="VARIABLES"), # Variables usable in SETUP and STEP Section
19+
dict(html_name='table sectionedit10', var_name="DATA_TYPES"), # Data types (user input)
20+
dict(html_name='table sectionedit15', var_name="DATA_EXTRACTION"), # Data Extraction
21+
]
22+
23+
HTML = requests.get('https://docu.gsa-online.de/search_engine_ranker/script_manual').content
24+
PARSER = soup(HTML, 'lxml')
25+
RESULTS = []
26+
27+
28+
def parse_table(data: dict):
29+
_html_name = data['html_name']
30+
31+
rows = PARSER.findAll('div', **dict(class_=_html_name))[0].find('table').find_all('tr')[1:]
32+
33+
_return = []
34+
35+
for r in rows:
36+
a = r.find_all('td')
37+
v = a[0].text.rstrip() # variable
38+
d = a[1].text.rstrip()\
39+
.replace('<', '&lt;')\
40+
.replace('>', '&gt;')\
41+
.replace("'", "&apos;")\
42+
.replace('"', "&quot;")\
43+
.replace("&", "&amp;") # description
44+
_return.append({v: d})
45+
print(d)
46+
return _return
47+
48+
49+
for table in TABLES:
50+
need = parse_table(table)
51+
print(table['var_name'], need)
52+
53+
for x in need:
54+
for k, v in x.items():
55+
data = SUBLIME_SNIPPET.format((k+'=').lower(), '{1}', v, k).replace('\n', '').replace('\t', '')
56+
file_name = './sublime_snippets/{0}.sublime-snippet'.format(k
57+
.replace('\n', '')
58+
.replace('\t', '')
59+
.replace('/', '')
60+
.replace('\\', ''))
61+
# write snippet
62+
file = open(file_name, 'w+', encoding='utf-8')
63+
file.write(data)
64+
file.close()
65+
# write help
66+
file2_name = 'help_sublime_snippets.ini'
67+
file2 = open(file2_name, 'a', encoding='utf-8')
68+
file2.write(f"{k}\n{v}\n########################################\n")
69+
file2.close()

utils/help_sublime_snippets.ini

Lines changed: 739 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<snippet><content><![CDATA[download retries=${1}]]></content> <description> /Number of tries to submit or download something (default is 1).</description> <tabTrigger>Download retries</tabTrigger></snippet>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<snippet><content><![CDATA[link type=${1}]]></content> <description> /Defines the type of backlink created. Can be anything you want but you might want to use the types already used in other scripts.</description> <tabTrigger>Link type</tabTrigger></snippet>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<snippet><content><![CDATA[add fixed data add fixed data conditionremove fixed dataremove fixed data condition=${1}]]></content> <description> /This will add a form field if the thing in “add fixed data condition” is found on the webpage. This works only if both variables are defined. Don&amp;apos;t worry about this to much as you will probably never use this. It is only required if some sites add data to forms by javascript to prevent automated submissions. You can use “remove fixed data” to just remove that from the posting.Example: add fixed data=code=%captcha%;hidden=0add fixed data condition=code_sign;hidden_dataIf the webpage has anywhere the word “code_sign” in it we add a new form field called code that will be filled with a captcha. And if the word “hidden_data” is found we also add a new form field called “hidden” with the content “0”.</description> <tabTrigger>add fixed data add fixed data conditionremove fixed dataremove fixed data condition</tabTrigger></snippet>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<snippet><content><![CDATA[add keyword to search=${1}]]></content> <description> /1 = Add a keyword from the project to the search query0 = Never add a keyword to the search query2 = Add just sometimes a keyword to it if it seems to be useful (default)</description> <tabTrigger>add keyword to search</tabTrigger></snippet>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<snippet><content><![CDATA[allow data url=${1}]]></content> <description> /0 = do not allow data URLs → gets removed1 = allow them (default)This will remove e.g. images from the article that are Data-URLs</description> <tabTrigger>allow data url</tabTrigger></snippet>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<snippet><content><![CDATA[allow html=${1}]]></content> <description> /0 = No html allowed1 = html is allowed&amp;lt;text&amp;gt; = If the text appears on the webpage we will allow html. HTML will be removed from your defined content if not supported by the engine (transformed into text only).</description> <tabTrigger>allow html</tabTrigger></snippet>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<snippet><content><![CDATA[allow return=${1}]]></content> <description> /0 = no return/line feed allowed1 = return/line feed is allowed&amp;lt;text&amp;gt; = If the text appears on the webpage we will allow a return/line feed.</description> <tabTrigger>allow return</tabTrigger></snippet>

0 commit comments

Comments
 (0)