Skip to content

Instantly share code, notes, and snippets.

from scrapy.item import Item, Field
class QuoteItem(Item):
quote_content = Field()
tags = Field()
author_name = Field()
author_birthday = Field()
author_bornlocation = Field()
author_bio = Field()
import scrapy
class QuotesSpider(scrapy.Spider):
name = "quotes"
start_urls = ['http://quotes.toscrape.com']
def parse(self, response):
# self.logger.info('hello this is my first spider')
quotes = response.css('div.quote')
def yield_demo(n):
for j in range(n):
yield triple(j)
print("j is:", j)
print("end of yield_demo")
def triple(m):
print("inside triple call", m)
return m*3
import scrapy
class QuotesSpider(scrapy.Spider):
name = "quotes"
start_urls = ['http://quotes.toscrape.com']
def parse(self, response):
self.logger.info('hello this is my first spider')
quotes = response.css('div.quote')
> contractInstance = VotingContract.at(deployedContract.address)
Contract {
_eth:
Eth {
_requestManager: RequestManager { provider: [HttpProvider], polls: {}, timeout: null },
getBalance: { [Function: send] request: [Function: bound ], call: 'eth_getBalance' },
getStorageAt: { [Function: send] request: [Function: bound ], call: 'eth_getStorageAt' },
getCode: { [Function: send] request: [Function: bound ], call: 'eth_getCode' },
getBlock: { [Function: send] request: [Function: bound ], call: [Function: blockCall] },
getUncle: { [Function: send] request: [Function: bound ], call: [Function: uncleCall] },
> abiDefinition = JSON.parse(compiledCode.contracts[':Voting'].interface)
[ { constant: true,
inputs: [ [Object] ],
name: 'totalVotesFor',
outputs: [ [Object] ],
payable: false,
stateMutability: 'view',
type: 'function' },
{ constant: true,
inputs: [ [Object] ],
wifi-roaming-128-4-185-34:chapter1 harrywang$ node
> Web3 = require('web3')
{ [Function: Web3]
providers:
{ HttpProvider: [Function: HttpProvider],
IpcProvider: [Function: IpcProvider] } }
> web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
Web3 {
_requestManager:
RequestManager {
@harrywang
harrywang / selenium-test.py
Created October 16, 2017 13:40
selenium test example
import re
import threading
import time
import unittest
from selenium import webdriver
from app import create_app
# this test case is an example for selenium based test case, not for real use
# this is a demo to show login using selenium
<!DOCTYPE html>
<html>
<head>
<title>Baker's Bike Shop</title>
<link href="https://fonts.googleapis.com/css?family=Abel|Amatic+SC|Raleway:100,200,300,400,500,600,700,800,900" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="navigation">
body {
background-color: #FFF;
margin: 0;
padding: 0;
}
#cover {
height: 900px;
position: relative;
top: -55px;