This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.16; | |
use warnings; | |
use autodie qw( :all ); | |
use utf8::all; | |
use List::MoreUtils qw( uniq any ); | |
use Benchmark qw( cmpthese :hireswallclock ); | |
my %file_names = (); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
use warnings; | |
use utf8::all; | |
use File::Slurp qw( read_file ); | |
my $pattern_list = do 'fw.pl'; | |
my @patterns = keys $pattern_list; | |
my $content = read_file( 'dracula.txt' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
use warnings; | |
use utf8::all; | |
use File::Slurp qw( read_file ); | |
my $pattern_list = do 'fw.pl'; | |
my @patterns = keys $pattern_list; | |
my $content = read_file( 'dracula.txt' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
use warnings; | |
use utf8::all; | |
use File::Slurp qw( read_file ); | |
... | |
my @patterns = map {qr/\b$_\b/ixms} keys $pattern_list; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
use warnings; | |
use utf8::all; | |
use List::Util qw( reduce ); | |
use List::MoreUtils qw( uniq any ); | |
use Path::Class::Rule; | |
use File::Slurp qw( read_file ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use v5.14; | |
use warnings; | |
use utf8::all; | |
use Encode; | |
use Data::Dumper; | |
use JSON::XS qw( decode_json ); | |
my $wl = '{"creche":"crèche", "¥":"£", "₡":"волн"}'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$html =~ m{ | |
>\s*$num\.</td>\s*<td>\s*<center>\s*<a\s+id=up_ | |
(\d+) # $1 -> id | |
\s+href="vote\?for=\g1&dir=up&whence=[%a-e0-9]+">\s*<img\s+src="http://yc | |
ombinator\.com/images/grayarrow\.gif"\s+border=\d+\s+vspace=\d+\s+hspace= | |
\d+>\s*</a>\s*<span\s+id=down_\g1>\s*</span>\s*</center>\s*</td>\s*<td\s+ | |
class="title">\s*<a\s+href=" | |
([^"]+) # $2 -> uri | |
"> | |
([^<]+) # $3 -> desc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locatestarttagend = re.compile(r""" | |
<[a-zA-Z][-.a-zA-Z0-9:_]* # tag name | |
(?:[\s/]* # optional whitespace before attribute name | |
(?:(?<=['"\s/])[^\s/>][^\s/=>]* # attribute name | |
(?:\s*=+\s* # value indicator | |
(?:'[^']*' # LITA-enclosed value | |
|"[^"]*" # LIT-enclosed value | |
|(?!['"])[^>\s]* # bare value | |
) | |
)?(?:\s|/(?!>))* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Methods for supporting CSS selectors. | |
tag_name_re = re.compile('^[a-z0-9]+$') | |
# /^(\w+)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/ | |
# \---/ \---/\-------------/ \-------/ | |
# | | | | | |
# | | | The value | |
# | | ~,|,^,$,* or = | |
# | Attribute |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
import BeautifulSoup as soup | |
import requests | |
... | |
r = requests.get(host + page) | |
doc = soup.BeautifulSoup(r.content) | |
titles = doc.table.findAll(True, {'class': 'title'}) |