This file contains 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
import json | |
import falcon | |
FAKE_DB_MOVIE = [{ | |
"Title": "The Alienist", | |
"Year": "2018", | |
"Rated": "TV-MA", | |
"Released": "22 Jan 2018", | |
"Runtime": "60 min", | |
"Genre": "Drama, Mystery", |
This file contains 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
[error] | |
ImportError: No module named '_gdbm' | |
[solved] | |
sudo apt-get install python3.5-gdbm | |
[error] | |
ImportError: No module named 'apt_pkg' | |
[solved] | |
locate apt_pkg.so | |
sudo ln -s /usr/lib/python3/dist-packages/apt_pkg.cpython-34m-x86_64-linux-gnu.so /usr/lib/python3/dist-packages/apt_pkg.so |
This file contains 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 django import forms | |
from django.contrib import admin | |
from django.template.response import TemplateResponse | |
class RegularCreationAdminForm(forms.ModelForm): | |
class Meta: | |
model = ReactivationCoupon | |
fields = [ |
This file contains 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
export function getDayOfWeek(date) { | |
const dayOfWeek = new Date(date).getDay(); | |
return isNaN(dayOfWeek) ? null : ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][dayOfWeek]; | |
} | |
export function getMonthName(date) { | |
const monthNumer = new Date(date).getMonth(); | |
return isNaN(monthNumer) ? null : ['January', 'February', 'March', 'April', 'May', 'June', | |
'July', 'August', 'September', 'October', 'November', 'December'][monthNumer]; | |
} |
This file contains 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
import scrapy | |
from scrapy.contrib.pipeline.images import ImagesPipeline | |
from scrapymercado.constants import URLS_AND_NAMES | |
class ScrapymercadoPipeline(ImagesPipeline): | |
def get_media_requests(self, item, info): | |
for image_url in item.get('image_urls', []): | |
yield scrapy.Request(image_url, meta={'filepatch': URLS_AND_NAMES.get(image_url)}) |
This file contains 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
import scrapy | |
from scrapymercado.items import ProductsItem | |
from scrapymercado.constants import URL | |
class ProductImgSpider(scrapy.Spider): | |
name = "productsimg" | |
def start_requests(self): | |
max_page_number = 67 |
This file contains 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
import scrapy | |
from scrapymercado.items import ProductsItem | |
from scrapymercado.constants import URL | |
class ProductsSpider(scrapy.Spider): | |
name = "products" | |
def start_requests(self): | |
max_page_number = 67 |
This file contains 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
import requests | |
from bs4 import BeautifulSoup | |
url = 'http://www.someurl.com.br/products' | |
headers = { | |
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36' | |
} | |
r = requests.get(url, headers=headers, timeout=5) |
NewerOlder