Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def parse_proxy(proxy_html):
# We get the chunk of code corresponding to the country...
country_html = regex.COUNTRY_HTML.search(proxy_html).group(0)
# ...and we parse it
country = regex.COUNTRY.search(country_html).group(1)
country = regex.COUNTRY.search(country_html).group(1).strip()

# We get the chunk of code corresponding to the speed...
speed_html = regex.SPEED_HTML.search(proxy_html).group(1)
Expand All @@ -75,8 +75,8 @@ def parse_proxy(proxy_html):
# We get the chunk of code corresponding to the type and anonymity...
match = regex.TYPE_ANONYMITY.search(proxy_html)
# ...and we parse it
type = match.group(1)
anonymity = match.group(2)
type = match.group(1).strip()
anonymity = match.group(2).strip()

# We return a tuple
return ip, int(port), type, country, anonymity, speed, connection_time
Expand Down
6 changes: 3 additions & 3 deletions regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
PROXY_HTML = re.compile(r'<tr class=".*?</tr>', flags=re.DOTALL)

# This regex corresponds to the HTML code containing the IP:port of a proxy
IP_PORT_HTML = re.compile(r'<td><span><style>.*?</td>\s*<td>.*?</td>',
IP_PORT_HTML = re.compile(r'<td>\s*?<span>\s*?<style>.*?</td>\s*<td>.*?</td>',
flags=re.DOTALL)

# This regex is used to find the class which won't be displayed in the IP:port
Expand All @@ -48,7 +48,7 @@

# This regex is used to recover the HTML code containing the country in the
# proxy HTML code
COUNTRY_HTML = re.compile(r'<span class="country".*?>.*?</span>',
COUNTRY_HTML = re.compile(r'class="country".*?\/>.*?</span>',
re.DOTALL)

# This regex is used to recover the country
Expand All @@ -70,5 +70,5 @@

# This regex is used to recover the type and anonymity level in the proxy
# HTML code
TYPE_ANONYMITY = re.compile(r'<td>(.*?)</td>\s*<td.*?>(.*)</td>')
TYPE_ANONYMITY = re.compile(r'<td>\s*(.*)\s*</td>\s*<td.*?>\s*(.*)</td>\s*</tr>')