Commit ac61c088 authored by Sacha's avatar Sacha Committed by SXibolet@2PITAU
Browse files

now using Tor for NYT API calls. closes #8

parent cf270ddc
......@@ -17,3 +17,4 @@ notes.rst
nohup.out
mongo-c-driver-1.3.0
mongo-c-driver
pytorctl
......@@ -22,6 +22,7 @@ from functools import partial
from operator import is_not
from nltk.corpus import stopwords
from twython.exceptions import TwythonAuthError
import tor_query
MAX_ATTEMPTS = 6
......@@ -153,7 +154,6 @@ class Article(object):
# we'll split into paragraphs for easier reading if training
res = ('|*^*|' if training else ' ').join(p.text for p in body)
jar.clear()
print(res)
return res
......@@ -167,9 +167,6 @@ def article_search(keyword, training=False):
today = datetime.date.today()
last_week = today - datetime.timedelta(days=11)
opener = urllib2.build_opener()
opener.addheaders = [('User-Agent', NYT_UA)]
params = urllib.urlencode({
'q': keyword,
'begin_date': nyt_query_date(last_week),
......@@ -178,7 +175,8 @@ def article_search(keyword, training=False):
'facet_field': 'source'
})
response = opener.open('%s%s' % (ARTICLE_SEARCH_BASE, params))
tor_query.renew_connection()
response = tor_query.query('%s%s' % (ARTICLE_SEARCH_BASE, params))
# an Article will be None if it doesn't have body text (thus the partial)
# return an array of Article objects that have a body text
return filter(partial(is_not, None),
......@@ -203,9 +201,10 @@ def article_comments(url, offset=0, training=False):
})
try:
response = urllib2.urlopen('%s%s' % (COMMENT_BASE, params))
response = tor_query.query('%s%s' % (COMMENT_BASE, params))
except urllib2.HTTPError:
# max requests exceeded (>5k queries or >30 / second)
tor_query.renew_connection()
curr_key += 1
i -= 1
break
......
......@@ -18,7 +18,9 @@ Please use Python 2.7.x
#. ``$ pip install virtualenv``
#. ``$ virtualenv venv``
#. ``$ . venv/bin/activate``
#. ``$ pip install -r requirements.txt`` will install requirements into the virtual environment to limit bloat on your actual machine
#. ``$ pip install -r requirements.txt`` will install requirements into the virtual environment to limit bloat on your actual machine.
#. ``git clone https://github.com/aaronsw/pytorctl``
#. ``pip install pytorctl/``
#. ``$ python``
- ``>>> import nltk``
- ``>>> nltk.download('stopwords', 'punkt')``
......
pytorctl @ 02b38bc2
Subproject commit 02b38bc208b58952a9886ce36b2de515d5f7fff3
......@@ -67,15 +67,20 @@ input[type="submit"] {
cursor: pointer;
min-width: 100px;
height: 40px;
background-color: #e9e9e9;
border: 1px solid #c3c3c3;
color: #333;
padding: 4px;
outline: 0;
border-radius: 0;
-webkit-appearance: none;
@include transition(0.15s);
&:hover { border: 1px solid #a3a3a3; }
background-color: #e9e9e9;
border: 1px solid #c3c3c3;
&:hover {
border-color: #a3a3a3;
}
&:focus, &:active { outline: 0; }
&:active {
-webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
......
This diff is collapsed.
This diff is collapsed.
html,ul,body,header,input,span,form{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;-webkit-text-size-adjust:100%}body{font-family:"Palatino LT", "Palatino Linotype", Palatino, Baskerville, "Bodoni MT", Garamond, Trebuchet, serif !important;font-variant-numeric:oldstyle-nums diagonal-fractions slashed-zero;text-rendering:optimizeLegibility;font-size:1em;word-wrap:break-word}h1,h2,h3,h4,h5{font-family:"Zapf Humanist 601", Optima, "Optima Nova", "URW Imperial", Amira, "Chianti BT", sans-serif !important;font-weight:700 !important}h1,h2,h3,h4,h5{text-transform:uppercase}h1{font-size:130%}h2{font-size:110%}h3{font-size:90%}h4{font-size:75%}h5{font-size:60%}input{outline:0;box-shadow:none;-webkit-tap-highlight-color:transparent}img{max-width:100%;height:auto;margin:auto}a{-webkit-tap-highlight-color:transparent;text-decoration:none;color:inherit;border-bottom:1px dotted;line-height:130%;word-wrap:break-word}a:hover,a:active{color:#ed0000;border-bottom:1px solid;text-decoration:none}input.field{padding:6px 12px;color:#555;border-bottom:1px dashed #d9d9d9;-webkit-border-radius:1px;-moz-border-radius:1px;-ms-border-radius:1px;border-radius:1px;margin:0 auto;margin-bottom:5px;height:20px;width:70%;text-align:center}input[type="submit"]{cursor:pointer;min-width:100px;height:40px;background-color:#e9e9e9;border:1px solid #c3c3c3;color:#333;padding:4px;outline:0;border-radius:0;-webkit-appearance:none;-webkit-transition:all 0.15s ease-in-out 0s;-moz-transition:all 0.15s ease-in-out 0s;-ms-transition:all 0.15s ease-in-out 0s;transition:all 0.15s ease-in-out 0s}input[type="submit"]:hover{border:1px solid #a3a3a3}input[type="submit"]:focus,input[type="submit"]:active{outline:0}input[type="submit"]:active{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}input::-moz-focus-inner{border:0}footer{margin:5em 0 0.5em 0;width:95%;color:#b0b0b0;font-size:12px;text-align:center}footer p{padding-top:10px;line-height:150%}div#message,div#error{position:fixed;font-size:90%;overflow:hidden;padding:3px;top:0;background-color:#a3a3a3;color:#fff;text-align:center;width:100%}div#message a,div#error a{color:#fff}div#error{background-color:#edb43a}@media (max-width: 400px){div#error,div#message,div#error{font-size:smaller;opacity:0.9}}ul#articles,ul#tweets{list-style:none}ul#articles li,ul#tweets li{page-break-inside:avoid;-webkit-column-break-inside:avoid;-moz-column-break-inside:avoid;-ms-column-break-inside:avoid;column-break-inside:avoid;break-inside:avoid-column}ul#articles li div.article,ul#tweets li div.tweet{background-color:#fff;border:2px solid #efefef;font-size:14px;-webkit-border-radius:2px;-moz-border-radius:2px;-ms-border-radius:2px;border-radius:2px}ul#articles{-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;-webkit-column-width:350px;-moz-column-width:350px;column-width:350px}ul#articles li{width:100%;margin-bottom:2em}ul#articles li div.article p{padding:5px}ul#articles li div.article a.title{padding:3px 5px 5px 5px;margin-top:5px;margin-bottom:2px;font-size:28px;display:block;border-bottom:none}ul#articles li div.article a.title:hover{color:#000}ul#articles li div.article p.url{padding:7px 5px 0px 5px;border-top:1px solid #e5e5e5;font-style:italic;text-align:center}ul#articles li div.article p.url a:after{content:" →"}ul#articles li div.article img{width:100%}ul#articles li div.most-controversial{border:2px solid #f90101}ul#articles li div.least-controversial{border:2px solid #00933b}ul#tweets{margin-top:2em;-webkit-column-width:150px;-moz-column-width:150px;column-width:150px;-webkit-column-gap:5px;-moz-column-gap:5px;column-gap:5px}ul#tweets li{width:100%;margin-bottom:5px}ul#tweets li div.tweet{padding:2px;overflow:hidden}ul#tweets li div.tweet a{color:inherit;text-decoration:none}ul#tweets li div.mad{border:2px solid #f90101}ul#tweets li div.happy{border:2px solid #00933b}footer{display:none}header{z-index:1;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;cursor:default;width:100%;height:55px;line-height:55px;background:#fff;border-bottom:1px solid #efefef;position:fixed}header a{-webkit-touch-callout:none}header>div{padding:0 15px 0 5px;display:inline}header>div>a.mini{display:none}header>div h1{text-align:left;display:inline;font-size:1.2em}header>div span#subtitle{opacity:0.4;padding-left:5px;font-size:smaller;font-style:italic}header>div span#right-header{float:right;padding-right:10px}header>div span#article_title{font-style:italic}header>div form{display:inline}header>div>form input{padding:6px 12px;line-height:1.5;-webkit-border-radius:2px;-moz-border-radius:2px;-ms-border-radius:2px;border-radius:2px;border-bottom:1px solid #d9d9d9;margin:0 auto;height:15px;width:30%}header input[type='text'].top_loading{background:url("img/loading.gif") no-repeat;background-position:98% 50%;background-size:20px 20px}header#sub{height:25px;line-height:25px;background:#f1f8fb;overflow:auto;white-space:nowrap;overflow-y:hidden;color:#2b6dad;border-bottom:1px solid #efefef;position:fixed;top:56px;min-width:100%;text-align:center;font-size:smaller;font-style:italic}main{padding:4em 1em}main input.loading{background:url("img/loading.gif") no-repeat;background-size:20px 20px;padding:10px 10px 10px 36px;background-position:10% 50%}main>form{margin-bottom:10px;text-align:center}main>form input[type="text"]{margin-bottom:10px;width:275px;border-bottom:1px solid #d9d9d9}main div.featured_keywords{display:table;padding-bottom:1em;margin:0 auto}main div.featured_keywords dl.left{float:left;width:50%}main div.featured_keywords dl.right{float:right;width:50%}main div.featured_keywords dt{float:left;width:7.5em;padding:1ex .5em 0 .5em;text-align:right;font-weight:bold}main div.featured_keywords dd{margin:0 0 0 8.5em;padding:1ex 0.5em;text-align:left;border-left:1px solid #888}main div.featured_keywords dd span{white-space:nowrap}main ul.details{-webkit-column-break-inside:avoid;-moz-column-break-inside:avoid;-ms-column-break-inside:avoid;column-break-inside:avoid;list-style:none;margin:0 0 10px 0;padding:0}main ul.details li{display:inline}main ul.details li>span{line-height:30px;-webkit-border-radius:2px;-moz-border-radius:2px;-ms-border-radius:2px;border-radius:2px;border:1px solid #d9d9d9;padding:2px}main article{text-align:justify;line-height:150%}main article a,main article a:hover,main article a:active{border-bottom:none;color:#fff;background-color:#337ab7}main article a{text-decoration:none;font-weight:700}main article a:hover,main article a:active{background-color:#2e6da4}main article+p{-webkit-transition:all 0.3s ease-in-out 0s;-moz-transition:all 0.3s ease-in-out 0s;-ms-transition:all 0.3s ease-in-out 0s;transition:all 0.3s ease-in-out 0s;opacity:0.6}main article+p:hover{opacity:1.0}main mark{line-height:25px;color:#2b6dad;background-color:#f1f8fb;-webkit-border-radius:2px;-moz-border-radius:2px;-ms-border-radius:2px;border-radius:2px;padding:2px}main .disabled{cursor:not-allowed;background-color:#f9f9f9}main .disabled:active{color:#fff;background-color:#edb43a}span.danger{color:#fff;background-color:#d43f3a;padding:2px;-webkit-border-radius:2px;-moz-border-radius:2px;-ms-border-radius:2px;border-radius:2px}figcaption{margin:10px 0 10px 0}@media (max-width: 700px){header>div span#right-header,header>div>a{font-size:12px}header#sub{font-size:12px;top:41px}.non-essentials{display:none}header{height:40px;line-height:40px}header h1{font-size:.7em}}@media (max-width: 620px){main div.featured_keywords dt{writing-mode:vertical-rl}}@media (max-width: 520px){main div.featured_keywords dl.left,main div.featured_keywords dl.right{float:none}span.danger{display:block}input[type='text'].top_loading{height:40px}}@media (max-width: 415px){header>div>a.mini{display:inline}header>div>a.lg{display:none}}
html,ul,body,header,input,span,form{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;-webkit-text-size-adjust:100%}body{font-family:"Palatino LT", "Palatino Linotype", Palatino, Baskerville, "Bodoni MT", Garamond, Trebuchet, serif !important;font-variant-numeric:oldstyle-nums diagonal-fractions slashed-zero;text-rendering:optimizeLegibility;font-size:1em;word-wrap:break-word}h1,h2,h3,h4,h5{font-family:"Zapf Humanist 601", Optima, "Optima Nova", "URW Imperial", Amira, "Chianti BT", sans-serif !important;font-weight:700 !important}h1,h2,h3,h4,h5{text-transform:uppercase}h1{font-size:130%}h2{font-size:110%}h3{font-size:90%}h4{font-size:75%}h5{font-size:60%}input{outline:0;box-shadow:none;-webkit-tap-highlight-color:transparent}img{max-width:100%;height:auto;margin:auto}a{-webkit-tap-highlight-color:transparent;text-decoration:none;color:inherit;border-bottom:1px dotted;line-height:130%;word-wrap:break-word}a:hover,a:active{color:#ed0000;border-bottom:1px solid;text-decoration:none}input.field{padding:6px 12px;color:#555;border-bottom:1px dashed #d9d9d9;-webkit-border-radius:1px;-moz-border-radius:1px;-ms-border-radius:1px;border-radius:1px;margin:0 auto;margin-bottom:5px;height:20px;width:70%;text-align:center}input[type="submit"]{cursor:pointer;min-width:100px;height:40px;color:#333;padding:4px;outline:0;border-radius:0;-webkit-appearance:none;-webkit-transition:all 0.15s ease-in-out 0s;-moz-transition:all 0.15s ease-in-out 0s;-ms-transition:all 0.15s ease-in-out 0s;transition:all 0.15s ease-in-out 0s;background-color:#e9e9e9;border:1px solid #c3c3c3}input[type="submit"]:hover{border-color:#a3a3a3}input[type="submit"]:focus,input[type="submit"]:active{outline:0}input[type="submit"]:active{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}input::-moz-focus-inner{border:0}footer{margin:5em 0 0.5em 0;width:95%;color:#b0b0b0;font-size:12px;text-align:center}footer p{padding-top:10px;line-height:150%}div#message,div#error{position:fixed;font-size:90%;overflow:hidden;padding:3px;top:0;background-color:#a3a3a3;color:#fff;text-align:center;width:100%}div#message a,div#error a{color:#fff}div#error{background-color:#edb43a}@media (max-width: 400px){div#error,div#message,div#error{font-size:smaller;opacity:0.9}}ul#articles,ul#tweets{list-style:none}ul#articles li,ul#tweets li{page-break-inside:avoid;-webkit-column-break-inside:avoid;-moz-column-break-inside:avoid;-ms-column-break-inside:avoid;column-break-inside:avoid;break-inside:avoid-column}ul#articles li div.article,ul#tweets li div.tweet{background-color:#fff;border:2px solid #efefef;font-size:14px;-webkit-border-radius:2px;-moz-border-radius:2px;-ms-border-radius:2px;border-radius:2px}ul#articles{-webkit-column-gap:10px;-moz-column-gap:10px;column-gap:10px;-webkit-column-width:350px;-moz-column-width:350px;column-width:350px}ul#articles li{width:100%;margin-bottom:2em}ul#articles li div.article p{padding:5px}ul#articles li div.article a.title{padding:3px 5px 5px 5px;margin-top:5px;margin-bottom:2px;font-size:28px;display:block;border-bottom:none}ul#articles li div.article a.title:hover{color:#000}ul#articles li div.article p.url{padding:7px 5px 0px 5px;border-top:1px solid #e5e5e5;font-style:italic;text-align:center}ul#articles li div.article p.url a:after{content:" →"}ul#articles li div.article img{width:100%}ul#articles li div.most-controversial{border:2px solid #f90101}ul#articles li div.least-controversial{border:2px solid #00933b}ul#tweets{margin-top:2em;-webkit-column-width:150px;-moz-column-width:150px;column-width:150px;-webkit-column-gap:5px;-moz-column-gap:5px;column-gap:5px}ul#tweets li{width:100%;margin-bottom:5px}ul#tweets li div.tweet{padding:2px;overflow:hidden}ul#tweets li div.tweet a{color:inherit;text-decoration:none}ul#tweets li div.mad{border:2px solid #f90101}ul#tweets li div.happy{border:2px solid #00933b}footer{display:none}header{z-index:1;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;cursor:default;width:100%;height:55px;line-height:55px;background:#fff;border-bottom:1px solid #efefef;position:fixed}header a{-webkit-touch-callout:none}header>div{padding:0 15px 0 5px;display:inline}header>div>a.mini{display:none}header>div h1{text-align:left;display:inline;font-size:1.2em}header>div span#subtitle{opacity:0.4;padding-left:5px;font-size:smaller;font-style:italic}header>div span#right-header{float:right;padding-right:10px}header>div span#article_title{font-style:italic}header>div form{display:inline}header>div>form input{padding:6px 12px;line-height:1.5;-webkit-border-radius:2px;-moz-border-radius:2px;-ms-border-radius:2px;border-radius:2px;border-bottom:1px solid #d9d9d9;margin:0 auto;height:15px;width:30%}header input[type='text'].top_loading{background:url("img/loading.gif") no-repeat;background-position:98% 50%;background-size:20px 20px}header#sub{height:25px;line-height:25px;background:#f1f8fb;overflow:auto;white-space:nowrap;overflow-y:hidden;color:#2b6dad;border-bottom:1px solid #efefef;position:fixed;top:56px;min-width:100%;text-align:center;font-size:smaller;font-style:italic}main{padding:4em 1em}main input.loading{background:url("img/loading.gif") no-repeat;background-size:20px 20px;padding:10px 10px 10px 36px;background-position:10% 50%}main>form{margin-bottom:10px;text-align:center}main>form input[type="text"]{margin-bottom:10px;width:275px;border-bottom:1px solid #d9d9d9}main div.featured_keywords{display:table;padding-bottom:1em;margin:0 auto}main div.featured_keywords dl.left{float:left;width:50%}main div.featured_keywords dl.right{float:right;width:50%}main div.featured_keywords dt{float:left;width:7.5em;padding:1ex .5em 0 .5em;text-align:right;font-weight:bold}main div.featured_keywords dd{margin:0 0 0 8.5em;padding:1ex 0.5em;text-align:left;border-left:1px solid #888}main div.featured_keywords dd span{white-space:nowrap}main ul.details{-webkit-column-break-inside:avoid;-moz-column-break-inside:avoid;-ms-column-break-inside:avoid;column-break-inside:avoid;list-style:none;margin:0 0 10px 0;padding:0}main ul.details li{display:inline}main ul.details li>span{line-height:30px;-webkit-border-radius:2px;-moz-border-radius:2px;-ms-border-radius:2px;border-radius:2px;border:1px solid #d9d9d9;padding:2px}main article{text-align:justify;line-height:150%}main article a,main article a:hover,main article a:active{border-bottom:none;color:#fff;background-color:#337ab7}main article a{text-decoration:none;font-weight:700}main article a:hover,main article a:active{background-color:#2e6da4}main article+p{-webkit-transition:all 0.3s ease-in-out 0s;-moz-transition:all 0.3s ease-in-out 0s;-ms-transition:all 0.3s ease-in-out 0s;transition:all 0.3s ease-in-out 0s;opacity:0.6}main article+p:hover{opacity:1.0}main mark{line-height:25px;color:#2b6dad;background-color:#f1f8fb;-webkit-border-radius:2px;-moz-border-radius:2px;-ms-border-radius:2px;border-radius:2px;padding:2px}main .disabled{cursor:not-allowed;background-color:#f9f9f9}main .disabled:active{color:#fff;background-color:#edb43a}span.danger{color:#fff;background-color:#d43f3a;padding:2px;-webkit-border-radius:2px;-moz-border-radius:2px;-ms-border-radius:2px;border-radius:2px}figcaption{margin:10px 0 10px 0}@media (max-width: 700px){header>div span#right-header,header>div>a{font-size:12px}header#sub{font-size:12px;top:41px}.non-essentials{display:none}header{height:40px;line-height:40px}header h1{font-size:.7em}}@media (max-width: 620px){main div.featured_keywords dt{writing-mode:vertical-rl}}@media (max-width: 520px){main div.featured_keywords dl.left,main div.featured_keywords dl.right{float:none}span.danger{display:block}input[type='text'].top_loading{height:40px}}@media (max-width: 415px){header>div>a.mini{display:inline}header>div>a.lg{display:none}}
/*# sourceMappingURL=home.css.map */
html,ul,body,header,input,span,form{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;-webkit-text-size-adjust:100%}body{font-family:"Palatino LT", "Palatino Linotype", Palatino, Baskerville, "Bodoni MT", Garamond, Trebuchet, serif !important;font-variant-numeric:oldstyle-nums diagonal-fractions slashed-zero;text-rendering:optimizeLegibility;font-size:1em;word-wrap:break-word}h1,h2,h3,h4,h5{font-family:"Zapf Humanist 601", Optima, "Optima Nova", "URW Imperial", Amira, "Chianti BT", sans-serif !important;font-weight:700 !important}h1,h2,h3,h4,h5{text-transform:uppercase}h1{font-size:130%}h2{font-size:110%}h3{font-size:90%}h4{font-size:75%}h5{font-size:60%}input{outline:0;box-shadow:none;-webkit-tap-highlight-color:transparent}img{max-width:100%;height:auto;margin:auto}a{-webkit-tap-highlight-color:transparent;text-decoration:none;color:inherit;border-bottom:1px dotted;line-height:130%;word-wrap:break-word}a:hover,a:active{color:#ed0000;border-bottom:1px solid;text-decoration:none}input.field{padding:6px 12px;color:#555;border-bottom:1px dashed #d9d9d9;-webkit-border-radius:1px;-moz-border-radius:1px;-ms-border-radius:1px;border-radius:1px;margin:0 auto;margin-bottom:5px;height:20px;width:70%;text-align:center}input[type="submit"]{cursor:pointer;min-width:100px;height:40px;background-color:#e9e9e9;border:1px solid #c3c3c3;color:#333;padding:4px;outline:0;border-radius:0;-webkit-appearance:none;-webkit-transition:all 0.15s ease-in-out 0s;-moz-transition:all 0.15s ease-in-out 0s;-ms-transition:all 0.15s ease-in-out 0s;transition:all 0.15s ease-in-out 0s}input[type="submit"]:hover{border:1px solid #a3a3a3}input[type="submit"]:focus,input[type="submit"]:active{outline:0}input[type="submit"]:active{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}input::-moz-focus-inner{border:0}footer{margin:5em 0 0.5em 0;width:95%;color:#b0b0b0;font-size:12px;text-align:center}footer p{padding-top:10px;line-height:150%}div#message,div#error{position:fixed;font-size:90%;overflow:hidden;padding:3px;top:0;background-color:#a3a3a3;color:#fff;text-align:center;width:100%}div#message a,div#error a{color:#fff}div#error{background-color:#edb43a}@media (max-width: 400px){div#error,div#message,div#error{font-size:smaller;opacity:0.9}}html{border-top:3px solid #ed0000}div#login{padding:1px 5px 20px 5px;text-align:center;-webkit-box-shadow:0 1px 2px 2px #eee;-moz-box-shadow:0 1px 2px 2px #eee;-ms-box-shadow:0 1px 2px 2px #eee;box-shadow:0 1px 2px 2px #eee;width:450px;margin:5em auto 0 auto}div#login form{margin-top:10px}div#login center{margin-top:1em}div#login div.g-recaptcha{display:table;margin:0 auto}div#login h2{font-size:1.1em;margin:20px 0 5px 0}@media (max-width: 520px){div#login{width:350px;font-size:14px}div#login input[type="submit"]{height:35px}}@media (max-width: 390px){div#login{width:320px;margin-top:2em}}@media (max-width: 320px){div#login{width:290px;margin:1em auto}html,body{margin:0}}
html,ul,body,header,input,span,form{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline;-webkit-text-size-adjust:100%}body{font-family:"Palatino LT", "Palatino Linotype", Palatino, Baskerville, "Bodoni MT", Garamond, Trebuchet, serif !important;font-variant-numeric:oldstyle-nums diagonal-fractions slashed-zero;text-rendering:optimizeLegibility;font-size:1em;word-wrap:break-word}h1,h2,h3,h4,h5{font-family:"Zapf Humanist 601", Optima, "Optima Nova", "URW Imperial", Amira, "Chianti BT", sans-serif !important;font-weight:700 !important}h1,h2,h3,h4,h5{text-transform:uppercase}h1{font-size:130%}h2{font-size:110%}h3{font-size:90%}h4{font-size:75%}h5{font-size:60%}input{outline:0;box-shadow:none;-webkit-tap-highlight-color:transparent}img{max-width:100%;height:auto;margin:auto}a{-webkit-tap-highlight-color:transparent;text-decoration:none;color:inherit;border-bottom:1px dotted;line-height:130%;word-wrap:break-word}a:hover,a:active{color:#ed0000;border-bottom:1px solid;text-decoration:none}input.field{padding:6px 12px;color:#555;border-bottom:1px dashed #d9d9d9;-webkit-border-radius:1px;-moz-border-radius:1px;-ms-border-radius:1px;border-radius:1px;margin:0 auto;margin-bottom:5px;height:20px;width:70%;text-align:center}input[type="submit"]{cursor:pointer;min-width:100px;height:40px;color:#333;padding:4px;outline:0;border-radius:0;-webkit-appearance:none;-webkit-transition:all 0.15s ease-in-out 0s;-moz-transition:all 0.15s ease-in-out 0s;-ms-transition:all 0.15s ease-in-out 0s;transition:all 0.15s ease-in-out 0s;background-color:#e9e9e9;border:1px solid #c3c3c3}input[type="submit"]:hover{border-color:#a3a3a3}input[type="submit"]:focus,input[type="submit"]:active{outline:0}input[type="submit"]:active{-webkit-box-shadow:inset 0 3px 5px rgba(0,0,0,0.125);box-shadow:inset 0 3px 5px rgba(0,0,0,0.125)}input::-moz-focus-inner{border:0}footer{margin:5em 0 0.5em 0;width:95%;color:#b0b0b0;font-size:12px;text-align:center}footer p{padding-top:10px;line-height:150%}div#message,div#error{position:fixed;font-size:90%;overflow:hidden;padding:3px;top:0;background-color:#a3a3a3;color:#fff;text-align:center;width:100%}div#message a,div#error a{color:#fff}div#error{background-color:#edb43a}@media (max-width: 400px){div#error,div#message,div#error{font-size:smaller;opacity:0.9}}html{border-top:3px solid #ed0000}div#login{padding:1px 5px 20px 5px;text-align:center;-webkit-box-shadow:0 1px 2px 2px #eee;-moz-box-shadow:0 1px 2px 2px #eee;-ms-box-shadow:0 1px 2px 2px #eee;box-shadow:0 1px 2px 2px #eee;width:450px;margin:5em auto 0 auto}div#login form{margin-top:10px}div#login center{margin-top:1em}div#login div.g-recaptcha{display:table;margin:0 auto}div#login h2{font-size:1.1em;margin:20px 0 5px 0}@media (max-width: 520px){div#login{width:350px;font-size:14px}div#login input[type="submit"]{height:35px}}@media (max-width: 390px){div#login{width:320px;margin-top:2em}}@media (max-width: 320px){div#login{width:290px;margin:1em auto}html,body{margin:0}}
/*# sourceMappingURL=login.css.map */
import urllib2
from config import TOR_PW, NYT_UA
from TorCtl import TorCtl
headers = {
'User-Agent': NYT_UA
}
def query(url):
proxy_support = urllib2.ProxyHandler({
'http' : '127.0.0.1:8118'
})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)
request = urllib2.Request(url, None, headers)
return urllib2.urlopen(request)
def renew_connection():
conn = TorCtl.connect(controlAddr='127.0.0.1',
controlPort=9051,
passphrase=TOR_PW)
conn.send_signal('NEWNYM')
conn.close()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment