Skip to content

Instantly share code, notes, and snippets.

View juanriaza's full-sized avatar
🎯
Focusing

Juan Riaza juanriaza

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am juanriaza on github.
  • I am juanriaza (https://keybase.io/juanriaza) on keybase.
  • I have a public key whose fingerprint is 828F C11C 27CA 7960 4256 9097 6642 B33E 75C9 8B89

To claim this, I am signing this object:

import asyncio
import requests
@asyncio.coroutine
def main():
loop = asyncio.get_event_loop()
future1 = loop.run_in_executor(None, requests.get, 'http://www.google.com')
future2 = loop.run_in_executor(None, requests.get, 'http://www.google.co.uk')
response1 = yield from future1
response2 = yield from future2
import requests
from lxml import etree
req = requests.get('http://pyvideo.org/category/50/pycon-us-2014/rss')
xml_tree = etree.fromstring(req.content)
urls = [v.get('url') for v in xml_tree.findall(".//enclosure")]
print ' && '.join(['youtube-dl %s -f best ' % u for u in urls])
import requests
from lxml.html import fromstring, iterlinks
# https://github.com/zacharyvoase/urlobject/
from urlobject import URLObject
url = 'http://juanriaza.com'
req = requests.get(url, verify=False)
html_tree = fromstring(req.content)
html_tree.make_links_absolute(url, resolve_base_href=True)
Step #1 - views https://github.com/enjoydjango/dwitter/compare/step-00-startproject...step-01-views
Step #2 - templates https://github.com/enjoydjango/dwitter/compare/step-01-views...step-02-templates
Step #3 - tags https://github.com/enjoydjango/dwitter/compare/step-02-templates...step-03-tags
Step #4 - filters https://github.com/enjoydjango/dwitter/compare/step-03-tags...step-04-filters
Step #5 - inheritance https://github.com/enjoydjango/dwitter/compare/step-04-filters...step-05-inheritance
Step #6 - models https://github.com/enjoydjango/dwitter/compare/step-05-inheritance...step-06-models
Step #7 - database https://github.com/enjoydjango/dwitter/compare/step-06-models...step-07-database
Step #8 - tweetpage https://github.com/enjoydjango/dwitter/compare/step-07-database...step-08-tweetpage
Step #9 - profile https://github.com/enjoydjango/dwitter/compare/step-08-tweetpage...step-09-profile
Step #10 - followers https://github.com/enjoydjango/dwitter/compare/step-09-profile...step-10-followers
{
"sessionId": "JoR1O6xasLEdZz8XGRtsvw__.oses4083-atg05",
"statusCode": "0",
"statusMessage": "The API Get Item by Id was executed successfully",
"errors": [],
"items": [
{
"deptId": "1215352562047",
"deptName": "Spirits & Alcopops",
"weight": "250ML",
@juanriaza
juanriaza / xpathfuncs.py
Last active August 29, 2015 14:07 — forked from rmax/xpathfuncs.py
"""XPath extension functions for lxml, inspired by:
https://gist.github.com/shirk3y/458224083ce5464627bc
Usage:
import xpathfuncs; xpathfuncs.setup()
"""
import string
@juanriaza
juanriaza / gist:3252ad6803aed6251a33
Last active August 29, 2015 14:09
Librecon API
import requests
mobile_code = 'XXXX'
req = requests.post('https://mobile.librecon.io/secret/api/v1/auth/code', data={'code': mobile_code})
auth_hash = req.json()['data']['assistant']['hash']
"""
{u'data': {u'assistant': {u'address': u'---',
u'cellPhone': u'---',
u'company': u'Scrapinghub',
u'country': u'SPAIN',
@juanriaza
juanriaza / cache.py
Last active August 29, 2015 14:11 — forked from kmike/cache.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import os
from scrapy.contrib.httpcache import FilesystemCacheStorage
from .dupefilter import splash_requst_fingerprint
class SplashAwareFSCacheStorage(FilesystemCacheStorage):
def _get_request_path(self, spider, request):
# -*- coding: utf-8 -*-
import requests
from mutagen import mp3, id3
req = requests.get(
'https://api.hypem.com/v2/users/juanriaza/favorites',
params={'count': 500, 'key': 'e51d64cf4ff893dfca4e2b5caa60bd21'})
if req.ok:
for song in req.json():