Skip to content

Instantly share code, notes, and snippets.

@harrywang
harrywang / ocr.json
Created March 14, 2020 14:45
google ocr result
{
"responses": [
{
"textAnnotations": [
{
"locale": "it",
"description": "Unilever\nDove Dove\n国潮盛富 全民嗨购,\nDe Dove Dove ve\nम\n满88送88礼包\n",
"boundingPoly": {
"vertices": [
{
@harrywang
harrywang / index.html
Created March 6, 2020 21:45 — forked from d3noob/index.html
Interactive tree v4 external json
<!DOCTYPE html>
<meta charset="UTF-8">
<style>
.node circle {
fill: #fff;
stroke: steelblue;
stroke-width: 3px;
}
@harrywang
harrywang / git_exercise.MD
Last active February 13, 2020 23:24
Git Exercise

Git Exercise

  • create a new repo
  • clone to local
  • .gitignore
  • Markdown
  • add a python file and run
  • commit the file and push
  • add another python file
  • commit the file and push

use wcba as an example:

login as admin. go to cpanel

Screen Shot 2019-09-22 at 10 38 59 AM

go to subdomain and create a new subdomain:

Screen Shot 2019-09-22 at 10 40 26 AM

class DuplicatesPipeline(object):
def __init__(self):
"""
Initializes database connection and sessionmaker.
Creates tables.
"""
engine = db_connect()
create_table(engine)
self.Session = sessionmaker(bind=engine)
class SaveQuotesPipeline(object):
def __init__(self):
"""
Initializes database connection and sessionmaker
Creates tables
"""
engine = db_connect()
create_table(engine)
self.Session = sessionmaker(bind=engine)
from sqlalchemy import create_engine, Column, Table, ForeignKey, MetaData
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import (
Integer, String, Date, DateTime, Float, Boolean, Text)
from scrapy.utils.project import get_project_settings
Base = declarative_base()
import scrapy
from scrapy.loader import ItemLoader
from tutorial.items import QuoteItem
class QuotesSpider(scrapy.Spider):
name = "quotes"
allowed_domains = ["toscrape.com"]
start_urls = ['http://quotes.toscrape.com/']
from scrapy.item import Item, Field
from scrapy.loader.processors import MapCompose, TakeFirst
from datetime import datetime
def remove_quotes(text):
# strip the unicode quotes
text = text.strip(u'\u201c'u'\u201d')
return text
from scrapy.item import Item, Field
from scrapy.loader.processors import MapCompose
def remove_quotes(text):
# strip the unicode quotes
text = text.strip(u'\u201c'u'\u201d')
return text