├── .gitignore ├── Best_selling_books └── dangdang.py ├── HFUT_Exam_Crawler ├── README.md ├── composer.json ├── crawler.php ├── exam.sql └── multi_process.sh ├── HFUT_Exam_Crawler_Py ├── .gitignore ├── DESCipher.py ├── crawler.py ├── crawler_somarx.py └── gen_doc.py ├── LICENSE ├── QZoneCrawl ├── .gitignore ├── QZoneCrawl.py ├── README.md └── screenshots │ ├── feeds.png │ └── log.png ├── README.md ├── Shanbay ├── elevator.py ├── grammar.md └── login.py └── util ├── downloader.py ├── redisCache.py ├── redisQueue.py └── throttle.py /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | vendor 3 | composer.lock 4 | __pycache__ 5 | output 6 | .DS_Store 7 | /private 8 | dump.rdb 9 | -------------------------------------------------------------------------------- /Best_selling_books/dangdang.py: -------------------------------------------------------------------------------- 1 | import re, os 2 | import pandas as pd 3 | import pickle, threading, time 4 | from util.downloader import Downloader 5 | from util.redisCache import RedisCache 6 | from collections import OrderedDict 7 | from lxml.html import fromstring 8 | 9 | 10 | class Dangdang: 11 | headers = { 12 | 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) ' 13 | 'Chrome/64.0.3282.186 Safari/537.36 ' 14 | } 15 | url = 'http://bang.dangdang.com/books/bestsellers/{}-{}-{}' 16 | 17 | def __init__(self): 18 | if not os.path.exists('output'): 19 | os.mkdir('output') 20 | self.bs_books = {} 21 | self.stopped = False 22 | self.queue = [] 23 | self.category_dict = {} 24 | self.downloader = Downloader(0, RedisCache()) 25 | pass 26 | 27 | def get_category_list(self): 28 | url = 'http://bang.dangdang.com/books/bestsellers/' 29 | res = self.downloader(url) 30 | html = fromstring(res) 31 | self.category_dict = { 32 | cid.attrib['category_path']: cid.cssselect('a')[0].text for cid in 33 | html.cssselect('#sortRanking .side_nav') 34 | } 35 | 36 | def get_books_list(self, cid='01.03.00.00.00.00', idx='month-2018-2-2', page=1): 37 | books = [] 38 | for page in range(page, 25 + 1): 39 | print('page =', page) 40 | res = self.downloader(self.url.format(cid, idx, page)) 41 | html = fromstring(res) 42 | for lst in html.cssselect('.bang_list li'): 43 | book_url = lst.cssselect('.name a')[0].attrib['href'] 44 | try: 45 | publish_date = re.findall('\d{4}-\d{2}-\d{2}', lst.cssselect('.publisher_info')[0].text_content())[0] 46 | except IndexError: 47 | publish_date = None 48 | book = OrderedDict( 49 | rank=lst.cssselect('.number')[0].text, 50 | name=lst.cssselect('.name a')[0].attrib['title'], 51 | publish_date=publish_date, 52 | ISBN=None, 53 | price=None, 54 | url=book_url 55 | ) 56 | # book.update(self.get_book_info(book_url)) 57 | # print(book) 58 | books.append(book) 59 | 60 | self.bs_books[cid] = books 61 | 62 | def _update_book_info(self, cid, bid, book_url): 63 | book = self.bs_books[cid][bid] 64 | if not book['ISBN'] or not book['price']: 65 | res = self.downloader(book_url) 66 | html = fromstring(res) 67 | try: 68 | book.update({ 69 | 'ISBN': re.findall('国际标准书号ISBN:(\d+)', html.cssselect('ul.key')[0].text_content())[0], 70 | 'price': html.cssselect('#original-price')[0].text_content().strip() 71 | }) 72 | except IndexError: 73 | print(book_url) 74 | 75 | print(book['name'], book['ISBN']) 76 | 77 | def update_books_info(self, max_threads=4): 78 | self.queue = [] 79 | for cid, books_info in self.bs_books.items(): 80 | for bid, book_info in enumerate(books_info): 81 | self.queue.append((cid, bid, book_info['url'])) 82 | 83 | def mt(): 84 | while not self.stopped and len(self.queue): 85 | book_ifo = self.queue.pop() 86 | self._update_book_info(*book_ifo) 87 | print('remain: ', len(self.queue)) 88 | 89 | threads = [] 90 | while not self.stopped and (threads or len(self.queue)): 91 | for thread in threads: 92 | if not thread.is_alive(): 93 | threads.remove(thread) 94 | 95 | while len(threads) < max_threads and len(self.queue): 96 | thread = threading.Thread(target=mt, daemon=True) 97 | thread.start() 98 | threads.append(thread) 99 | 100 | # don't block it 101 | # for thread in threads: 102 | # thread.join() 103 | 104 | time.sleep(1) 105 | 106 | self.save_obj() 107 | 108 | def save_obj(self): 109 | with open('output/category_dict.pkl', 'wb') as f: 110 | pickle.dump(self.category_dict, f, pickle.HIGHEST_PROTOCOL) 111 | with open('output/bs_books.pkl', 'wb') as f: 112 | pickle.dump(self.bs_books, f, pickle.HIGHEST_PROTOCOL) 113 | 114 | def load_obj(self): 115 | with open('output/category_dict.pkl', 'rb') as f: 116 | self.category_dict = pickle.load(f) 117 | with open('output/bs_books.pkl', 'rb') as f: 118 | self.bs_books = pickle.load(f) 119 | 120 | def save_books_list(self): 121 | writer = pd.ExcelWriter('output/当当网畅销书汇总 by netcan.xlsx') 122 | for cid, books in self.bs_books.items(): 123 | books_df = pd.DataFrame(books) 124 | books_df.to_excel(writer, self.category_dict[cid].replace('/', ''), index=False) 125 | writer.save() 126 | 127 | def get_all(self): 128 | self.get_category_list() 129 | for cnt, (cid, cname) in enumerate(self.category_dict.items()): 130 | print(cname, cnt + 1, '/', len(self.category_dict)) 131 | self.get_books_list(cid) 132 | self.save_obj() 133 | 134 | 135 | if __name__ == '__main__': 136 | dangdang = Dangdang() 137 | dangdang.get_all() 138 | -------------------------------------------------------------------------------- /HFUT_Exam_Crawler/README.md: -------------------------------------------------------------------------------- 1 | # HFUT_Exam_Crawler 2 | 合肥工业大学思政题库爬虫 3 | 4 | # 介绍 5 | 支持抓取的科目: 6 | * 毛中特 7 | * 思修 8 | * 马克思 9 | * 近代史 10 | 11 | # 原理 12 | php使用curl模拟登陆,然后dom分析html抓取至数据库。多进程支持。 13 | 14 | # 使用方法: 15 | Linux下执行: 16 | ``` 17 | # bash ./multi_process.sh 18 | ``` 19 | 20 | 参数修改: 21 | 22 | 如果需要改变抓取的题库,在`crawler.php`中修改参数: 23 | ``` 24 | /* Subject选项:(抓取的科目) 25 | 毛中特: mzdsxhzgteshzylltx 26 | 马克思: marxism 27 | 近代史: zgjdsgy 28 | 思修: sxddxyyfljc 29 | */ 30 | /* Chapter选项:(对应章节) 31 | 毛中特: 1-12 32 | 马克思: 0-7 33 | 近代史: 1-7 34 | 思修: 0-7 35 | */ 36 | 37 | $Options = array( 38 | 'Chapter'=>5, 39 | 'Subject'=>'mzdsxhzgteshzylltx', 40 | 'Uid'=>'2014218000' 41 | ); 42 | ``` 43 | 44 | -------------------------------------------------------------------------------- /HFUT_Exam_Crawler/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "require": { 3 | "shark/simple_html_dom": "dev-master" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /HFUT_Exam_Crawler/crawler.php: -------------------------------------------------------------------------------- 1 | 5, 19 | 'Subject'=>'mzdsxhzgteshzylltx', 20 | 'Uid'=>'2014218000' 21 | ); 22 | 23 | $db = mysqli_connect("127.0.0.1", "root", "123", "exam") or die("Couldn't connect database"); 24 | mysqli_query($db, "set names utf8"); 25 | 26 | function crawler() { 27 | global $Options; 28 | if($Options['Subject'] == 'mzdsxhzgteshzylltx') { 29 | if($Options['Chapter'] > 7) 30 | $EXAM_URL="10.111.100.107/exercise/singleChapter.asp?subtable=mzdsxhzgteshzylltx2&chapter=" . strval($Options['Chapter']-7) ."&sid=$Options[Uid]"; 31 | else 32 | $EXAM_URL="10.111.100.107/exercise/singleChapter.asp?subtable=mzdsxhzgteshzylltx1&chapter=$Options[Chapter]&sid=$Options[Uid]"; 33 | } 34 | else 35 | $EXAM_URL="10.111.100.107/exercise/singleChapter.asp?subtable=$Options[Subject]&chapter=$Options[Chapter]&sid=$Options[Uid]"; 36 | 37 | // echo $EXAM_URL; 38 | 39 | $ch = curl_init(); 40 | curl_setopt($ch, CURLOPT_URL, $EXAM_URL); 41 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 42 | $out = curl_exec($ch); 43 | curl_close($ch); 44 | $out = iconv("gb2312", "utf8", $out); 45 | return $out; 46 | } 47 | 48 | function get_data() { 49 | global $Options; 50 | global $db; 51 | 52 | $html = new simple_html_dom(); 53 | $html->load(crawler()); 54 | $data = $html->find('body table tbody tr td form table tbody tr input[type=hidden]'); 55 | // echo $html; 56 | 57 | foreach($data as $input) { 58 | if(substr($input->id, 0, 4) == 'cent') continue; 59 | if(substr($input->id, 0, 3) == 'ans') { 60 | // do something... 61 | $ans = $input->value; 62 | if(isset($a)) { 63 | if(strlen($ans) == 1) 64 | $type = 2; // 单选 65 | else 66 | $type = 3; // 多选 67 | } 68 | else 69 | $type = 1; // 判断 70 | 71 | if($type == 1) { 72 | $sql = "INSERT INTO `exam`.`$Options[Subject]` 73 | (`id`, `type`, `subject`, `a`, `b`, `c`, `d`, `answer`, `chapter`) VALUES 74 | (NULL, '1', '$ques', NULL, NULL, NULL, NULL, '$ans', '$Options[Chapter]')"; 75 | } else { 76 | $sql = "INSERT INTO `exam`.`$Options[Subject]` 77 | (`id`, `type`, `subject`, `a`, `b`, `c`, `d`, `answer`, `chapter`) VALUES 78 | (NULL, '$type', '$ques', '$a', '$b', '$c', '$d', '$ans', '$Options[Chapter]')"; 79 | } 80 | 81 | // echo "$sql
"; 82 | mysqli_query($db, $sql); 83 | 84 | // echo "Type: $type
"; 85 | // echo "Ques: $ques
"; 86 | // echo "A. $a
"; 87 | // echo "B. $b
"; 88 | // echo "C. $c
"; 89 | // echo "D. $d
"; 90 | // echo "Ans: $ans
"; 91 | 92 | $type = $ques = $a = $b = $c = $d = $ans = NULL; 93 | continue; 94 | } 95 | 96 | switch(substr($input->id, 0, 1)) { 97 | case 'q': 98 | $ques = $input->value; 99 | break; 100 | case 'a': 101 | $a = $input->value; 102 | break; 103 | case 'b': 104 | $b = $input->value; 105 | break; 106 | case 'c': 107 | $c = $input->value; 108 | break; 109 | case 'd': 110 | $d = $input->value; 111 | break; 112 | } 113 | } 114 | } 115 | 116 | // echo crawler(); 117 | get_data(); 118 | echo "已抓取:" . mysqli_num_rows(mysqli_query($db, "SELECT * FROM `$Options[Subject]`")) . "条\n"; 119 | 120 | mysqli_close($db); 121 | 122 | -------------------------------------------------------------------------------- /HFUT_Exam_Crawler/exam.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.0.10deb1 3 | -- http://www.phpmyadmin.net 4 | -- 5 | -- 主机: localhost 6 | -- 生成日期: 2016-06-18 17:30:56 7 | -- 服务器版本: 5.5.47-0ubuntu0.14.04.1 8 | -- PHP 版本: 5.5.9-1ubuntu4.17 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | SET time_zone = "+00:00"; 12 | 13 | 14 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 15 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 16 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 17 | /*!40101 SET NAMES utf8 */; 18 | 19 | -- 20 | -- 数据库: `exam` 21 | -- 22 | CREATE DATABASE IF NOT EXISTS `exam` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; 23 | USE `exam`; 24 | 25 | -- -------------------------------------------------------- 26 | 27 | -- 28 | -- 表的结构 `marxism` 29 | -- 30 | 31 | DROP TABLE IF EXISTS `marxism`; 32 | CREATE TABLE IF NOT EXISTS `marxism` ( 33 | `id` int(11) NOT NULL AUTO_INCREMENT, 34 | `type` int(11) NOT NULL, 35 | `subject` varchar(255) NOT NULL, 36 | `a` varchar(200) DEFAULT NULL, 37 | `b` varchar(200) DEFAULT NULL, 38 | `c` varchar(200) DEFAULT NULL, 39 | `d` varchar(200) DEFAULT NULL, 40 | `answer` varchar(200) NOT NULL, 41 | `chapter` varchar(200) NOT NULL, 42 | PRIMARY KEY (`id`), 43 | UNIQUE KEY `subject` (`subject`) 44 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 45 | 46 | -- 47 | -- 插入之前先把表清空(truncate) `marxism` 48 | -- 49 | 50 | TRUNCATE TABLE `marxism`; 51 | -- -------------------------------------------------------- 52 | 53 | -- 54 | -- 表的结构 `mzdsxhzgteshzylltx` 55 | -- 56 | 57 | DROP TABLE IF EXISTS `mzdsxhzgteshzylltx`; 58 | CREATE TABLE IF NOT EXISTS `mzdsxhzgteshzylltx` ( 59 | `id` int(11) NOT NULL AUTO_INCREMENT, 60 | `type` int(11) NOT NULL, 61 | `subject` varchar(255) NOT NULL, 62 | `a` varchar(200) DEFAULT NULL, 63 | `b` varchar(200) DEFAULT NULL, 64 | `c` varchar(200) DEFAULT NULL, 65 | `d` varchar(200) DEFAULT NULL, 66 | `answer` varchar(200) NOT NULL, 67 | `chapter` varchar(200) NOT NULL, 68 | PRIMARY KEY (`id`), 69 | UNIQUE KEY `subject` (`subject`) 70 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 71 | 72 | -- 73 | -- 插入之前先把表清空(truncate) `mzdsxhzgteshzylltx` 74 | -- 75 | 76 | TRUNCATE TABLE `mzdsxhzgteshzylltx`; 77 | -- -------------------------------------------------------- 78 | 79 | -- 80 | -- 表的结构 `sxddxyyfljc` 81 | -- 82 | 83 | DROP TABLE IF EXISTS `sxddxyyfljc`; 84 | CREATE TABLE IF NOT EXISTS `sxddxyyfljc` ( 85 | `id` int(11) NOT NULL AUTO_INCREMENT, 86 | `type` int(11) NOT NULL, 87 | `subject` varchar(255) NOT NULL, 88 | `a` varchar(200) DEFAULT NULL, 89 | `b` varchar(200) DEFAULT NULL, 90 | `c` varchar(200) DEFAULT NULL, 91 | `d` varchar(200) DEFAULT NULL, 92 | `answer` varchar(200) NOT NULL, 93 | `chapter` varchar(200) NOT NULL, 94 | PRIMARY KEY (`id`), 95 | UNIQUE KEY `subject` (`subject`) 96 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 97 | 98 | -- 99 | -- 插入之前先把表清空(truncate) `sxddxyyfljc` 100 | -- 101 | 102 | TRUNCATE TABLE `sxddxyyfljc`; 103 | -- -------------------------------------------------------- 104 | 105 | -- 106 | -- 表的结构 `zgjdsgy` 107 | -- 108 | 109 | DROP TABLE IF EXISTS `zgjdsgy`; 110 | CREATE TABLE IF NOT EXISTS `zgjdsgy` ( 111 | `id` int(11) NOT NULL AUTO_INCREMENT, 112 | `type` int(11) NOT NULL, 113 | `subject` varchar(255) NOT NULL, 114 | `a` varchar(200) DEFAULT NULL, 115 | `b` varchar(200) DEFAULT NULL, 116 | `c` varchar(200) DEFAULT NULL, 117 | `d` varchar(200) DEFAULT NULL, 118 | `answer` varchar(200) NOT NULL, 119 | `chapter` varchar(200) NOT NULL, 120 | PRIMARY KEY (`id`), 121 | UNIQUE KEY `subject` (`subject`) 122 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; 123 | 124 | -- 125 | -- 插入之前先把表清空(truncate) `zgjdsgy` 126 | -- 127 | 128 | TRUNCATE TABLE `zgjdsgy`; 129 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 130 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 131 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 132 | -------------------------------------------------------------------------------- /HFUT_Exam_Crawler/multi_process.sh: -------------------------------------------------------------------------------- 1 | ######################################################################### 2 | # File Name: multi_process.sh 3 | # Author: Netcan 4 | # Blog: http://www.netcan666.com 5 | # mail: 1469709759@qq.com 6 | # Created Time: 2016-06-18 六 19:45:32 CST 7 | ######################################################################### 8 | #!/bin/bash 9 | 10 | function multi_process { 11 | for i in {1..30} 12 | do 13 | php ./crawler.php & 14 | done 15 | wait 16 | } 17 | 18 | while :; 19 | do 20 | multi_process 21 | done 22 | -------------------------------------------------------------------------------- /HFUT_Exam_Crawler_Py/.gitignore: -------------------------------------------------------------------------------- 1 | *.db 2 | -------------------------------------------------------------------------------- /HFUT_Exam_Crawler_Py/DESCipher.py: -------------------------------------------------------------------------------- 1 | from Crypto.Cipher import DES 2 | 3 | 4 | class DESCipher: 5 | def __init__(self, key): 6 | if len(key) != 8: 7 | raise ValueError('Key must be 8 bytes long') 8 | self.cipher = DES.new(key, DES.MODE_ECB) 9 | 10 | def encrypt(self, content): 11 | if not isinstance(content, str): 12 | raise TypeError 13 | while len(content.encode()) % 8 != 0: 14 | content += chr(23) 15 | 16 | return self.cipher.encrypt(content) 17 | 18 | def decrypt(self, raw): 19 | if not isinstance(raw, bytes): 20 | raise TypeError 21 | content = self.cipher.decrypt(raw) 22 | length = len(raw) 23 | for c in content[::-1]: 24 | if c == 23: 25 | length -= 1 26 | else: 27 | break 28 | return content[:length].decode('utf8') 29 | 30 | -------------------------------------------------------------------------------- /HFUT_Exam_Crawler_Py/crawler.py: -------------------------------------------------------------------------------- 1 | from lxml.html import fromstring 2 | import sqlite3 3 | import requests 4 | from sqlite3 import IntegrityError 5 | 6 | 7 | class Exam: 8 | chapter_range = { 9 | 'mzdsxhzgteshzylltx': range(1, 12 + 1), 10 | 'marxism': range(0, 7 + 1), 11 | 'zgjdsgy': range(1, 7 + 1), 12 | 'sxddxyyfljc': range(0, 8 + 1) 13 | } 14 | # 宣城校区 15 | # url = "http://10.111.100.107/exercise/singleChapter.asp?subtable={}&chapter={}&sid={}" 16 | # 合肥校区? 17 | url = "http://222.195.7.159/exercise/singleChapter.asp?subtable={}&chapter={}&sid={}" 18 | headers = { 19 | 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) ' 20 | 'Chrome/62.0.3202.75 Safari/537.36 ' 21 | } 22 | 23 | def __init__(self, uid=2016218000, dbname='exam.db'): 24 | self.uid = uid 25 | self.db = sqlite3.connect(dbname) 26 | for table in Exam.chapter_range: 27 | self.db.execute(''' 28 | CREATE TABLE IF NOT EXISTS "{}"( 29 | [_id] integer PRIMARY KEY AUTOINCREMENT 30 | ,[type] INTEGER 31 | ,[subject] VARCHAR(255) COLLATE NOCASE UNIQUE 32 | ,[a] VARCHAR(200) COLLATE NOCASE 33 | ,[b] VARCHAR(200) COLLATE NOCASE 34 | ,[c] VARCHAR(200) COLLATE NOCASE 35 | ,[d] VARCHAR(200) COLLATE NOCASE 36 | ,[answer] VARCHAR(200) COLLATE NOCASE 37 | ,[chapter] VARCHAR(200) COLLATE NOCASE 38 | ,[collection] integer COLLATE NOCASE 39 | ,[myAnswer] varchar(200) COLLATE NOCASE 40 | ); 41 | '''.format(table)) 42 | 43 | def crawler(self): 44 | # 爬取题库并存储至sqlite数据库 45 | for subject in Exam.chapter_range: 46 | for chapter in Exam.chapter_range[subject]: 47 | retry_times = 0 48 | ques_count = 0 49 | while retry_times < 20: 50 | cur_ques_count = len(self.db.execute('select * from {}'.format(subject)).fetchall()) 51 | if cur_ques_count != ques_count: 52 | retry_times = 0 53 | ques_count = cur_ques_count 54 | print('{}已抓取'.format(subject), ques_count, '条,第 {}'.format(chapter), '章') 55 | else: 56 | retry_times += 1 57 | 58 | if subject == 'mzdsxhzgteshzylltx': 59 | if chapter > 7: 60 | r = requests.get(Exam.url.format(subject + '2', chapter - 7, self.uid), headers=Exam.headers) 61 | else: 62 | r = requests.get(Exam.url.format(subject + '1', chapter, self.uid), headers=Exam.headers) 63 | else: 64 | r = requests.get(Exam.url.format(subject, chapter, self.uid), headers=Exam.headers) 65 | 66 | r.encoding = 'gbk' 67 | html = r.text 68 | root = fromstring(html) 69 | 70 | questions = [q.value for q in root.cssselect('input[id^="question"]')] 71 | ans = [a.value for a in root.cssselect('input[id^="answer"]')] 72 | for qid, (question, ans) in enumerate(zip(questions, ans)): 73 | data = { 74 | 'chapter': str(chapter), 75 | 'question': question, # 题目 76 | 'answer': ans, 77 | 'a': str(), 78 | 'b': str(), 79 | 'c': str(), 80 | 'd': str(), 81 | } 82 | # 1判断 2单选 3多选 83 | data['answer'] = data['answer'].replace('O', '0') 84 | data['type'] = 1 if data['answer'] in '01' else \ 85 | 2 if len(data['answer']) == 1 else 3 86 | 87 | try: 88 | if data['type'] != 1: # 选择题 89 | for s in list('abcd'): 90 | data[s] = root.cssselect('input[id$="{}{}"]'.format(s, qid + 1))[0].value 91 | self.db.execute("INSERT INTO {} (type, subject, a, b, c, d, answer, chapter) VALUES (" 92 | "?, ?, ?, ?, ?, ?, ?, ?) ".format(subject), 93 | (data['type'], data['question'], 94 | data['a'], data['b'], data['c'], data['d'], 95 | data['answer'], data['chapter'])) 96 | else: 97 | self.db.execute( 98 | 'INSERT INTO {} (type, subject, a, b, c, d, answer, chapter) VALUES (?, ?, NULL, ' 99 | 'NULL, NULL, NULL, ?, ?)'.format(subject), 100 | (data['type'], data['question'], 101 | data['answer'], data['chapter'])) 102 | except IntegrityError: 103 | pass 104 | 105 | print('{}已抓取'.format(subject), ques_count, '条') 106 | 107 | self.db.commit() 108 | 109 | 110 | if __name__ == '__main__': 111 | exam = Exam() 112 | exam.crawler() -------------------------------------------------------------------------------- /HFUT_Exam_Crawler_Py/crawler_somarx.py: -------------------------------------------------------------------------------- 1 | import requests, sqlite3 2 | from lxml.html import fromstring 3 | from requests.compat import urljoin 4 | from sqlite3 import IntegrityError 5 | from DESCipher import DESCipher 6 | 7 | 8 | class Exam: 9 | url = 'http://www.somarx.cn/Chapter/ChapterList' 10 | headers = { 11 | 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) ' 12 | 'Chrome/62.0.3202.75 Safari/537.36 ' 13 | } 14 | chapter_range = { 15 | 'mzdsxhzgteshzylltx': [], 16 | 'marxism': [], 17 | 'zgjdsgy': [], 18 | 'sxddxyyfljc': [] 19 | } 20 | course_id = { 21 | 'mzdsxhzgteshzylltx': {'courseId': 3}, 22 | 'marxism': {'courseId': 1}, 23 | 'zgjdsgy': {'courseId': 2}, 24 | 'sxddxyyfljc': {'courseId': 4} 25 | } 26 | 27 | def __init__(self, password=None, dbname='exam_somarx.db'): 28 | self.cookies = requests.cookies.RequestsCookieJar() 29 | # 登陆后,获取session_id,保存id就能保持会话,不需要重复登陆了 30 | self.cookies.set('ASP.NET_SessionId', '', domain='www.somarx.cn', path='/') 31 | self.db = sqlite3.connect(dbname) 32 | self.cipher = DESCipher(password) if password else None 33 | for table in Exam.chapter_range: 34 | self.db.execute(''' 35 | CREATE TABLE IF NOT EXISTS "{}"( 36 | [_id] integer PRIMARY KEY AUTOINCREMENT 37 | ,[type] INTEGER 38 | ,[subject] VARCHAR(255) COLLATE NOCASE UNIQUE 39 | ,[a] VARCHAR(200) COLLATE NOCASE 40 | ,[b] VARCHAR(200) COLLATE NOCASE 41 | ,[c] VARCHAR(200) COLLATE NOCASE 42 | ,[d] VARCHAR(200) COLLATE NOCASE 43 | ,[e] VARCHAR(200) COLLATE NOCASE 44 | ,[answer] VARCHAR(200) COLLATE NOCASE 45 | ,[chapter] VARCHAR(200) COLLATE NOCASE 46 | ); 47 | '''.format(table)) 48 | 49 | def get_chapter_list(self): 50 | for course in Exam.course_id: 51 | if not Exam.chapter_range[course]: 52 | r = requests.get(Exam.url, params=Exam.course_id[course], cookies=self.cookies, headers=self.headers) 53 | html = fromstring(r.text) 54 | Exam.chapter_range[course] = [x.attrib['href'] for x in html.cssselect('.start-do')] 55 | 56 | def crawler(self): 57 | self.get_chapter_list() 58 | for course in Exam.chapter_range: 59 | for cid, chapter in enumerate(Exam.chapter_range[course]): 60 | r = requests.get(urljoin(self.url, chapter), cookies=self.cookies, headers=self.headers) 61 | html = fromstring(r.text) 62 | question = [q.text for q in html.cssselect('.question-word > p:nth-child(2)')] 63 | selection = html.cssselect('ol[type="A"]') 64 | right_ans = [a.text for a in html.cssselect('b.right-answer')] 65 | for ques, sel, ra in zip(question, selection, right_ans): 66 | if self.cipher: 67 | ques = self.cipher.encrypt(ques) 68 | 69 | if ra in '对错': 70 | ra = '1' if ra == '对' else '0' 71 | data = { 72 | 'chapter': str(cid if course != 'mzdsxhzgteshzylltx' else cid + 1), 73 | 'question': ques, # 题目 74 | 'answer': ra, 75 | 'a': str(), 76 | 'b': str(), 77 | 'c': str(), 78 | 'd': str(), 79 | 'e': str(), 80 | } 81 | # 1判断 2单选 3多选 82 | data['type'] = 1 if data['answer'] in '01' else \ 83 | 2 if len(data['answer']) == 1 else 3 84 | try: 85 | if data['type'] != 1: 86 | for s, sc in zip(list('abcde'), sel.xpath('li/p/text()')): 87 | data[s] = sc if not self.cipher else self.cipher.encrypt(sc) 88 | self.db.execute("INSERT INTO {} (type, subject, a, b, c, d, e, answer, chapter) VALUES (" 89 | "?, ?, ?, ?, ?, ?, ?, ?, ?) ".format(course), 90 | (data['type'], data['question'], 91 | data['a'], data['b'], data['c'], data['d'], data['e'], 92 | data['answer'], data['chapter'])) 93 | else: 94 | self.db.execute( 95 | "INSERT INTO {} (type, subject, answer, chapter) VALUES (?, ?, ?, ?)".format(course), 96 | (data['type'], data['question'], data['answer'], data['chapter'])) 97 | except IntegrityError: 98 | pass 99 | print('{}第{}章已抓取'.format(course, data['chapter']), len(question), '条') 100 | print('{}已抓取'.format(course), len(self.db.execute('select * from {}'.format(course)).fetchall()), '条') 101 | self.db.commit() 102 | 103 | 104 | if __name__ == '__main__': 105 | exam = Exam() 106 | exam.get_chapter_list() 107 | exam.crawler() 108 | -------------------------------------------------------------------------------- /HFUT_Exam_Crawler_Py/gen_doc.py: -------------------------------------------------------------------------------- 1 | import sqlite3 2 | from DESCipher import DESCipher 3 | from collections import namedtuple 4 | import os 5 | 6 | 7 | def gen_doc(db_name='exam_somarx.db', password=None): 8 | if not os.path.exists('output'): 9 | os.mkdir('output') 10 | cipher = DESCipher(password) if password else None 11 | db = sqlite3.connect(db_name) 12 | courses = ['mzdsxhzgteshzylltx', 'marxism', 'zgjdsgy', 'sxddxyyfljc'] 13 | # 没有方法的类,只有属性 14 | Question = namedtuple('Question', ['chapter', 'type', 'subject', 'a', 'b', 'c', 'd', 'e', 'answer']) 15 | sql = 'SELECT chapter, type, subject, a, b, c, d, e, answer FROM {} ORDER BY ABS(chapter), ABS(type);' 16 | types = [None, '判断题', '单选题', '多选题'] 17 | for course in courses: 18 | md = '' 19 | qs = [Question(*q) for q in 20 | db.execute(sql.format(course)).fetchall()] 21 | chapter = -1 22 | tye = -1 23 | 24 | for q in qs: 25 | if chapter != int(q.chapter): 26 | chapter = int(q.chapter) 27 | md += '## 第 {} 章\n'.format(chapter) 28 | if tye != q.type: 29 | tye = q.type 30 | md += '\n### {}\n'.format(types[tye]) 31 | qid = 1 32 | 33 | md += "{}. {} **{}**\n".format(qid, (cipher.decrypt(q.subject) if cipher else q.subject).strip(), 34 | q.answer.replace('0', '错').replace('1', '对') 35 | if q.answer in '01' else q.answer) 36 | # 选择题 37 | if tye != 1: 38 | md += '```\n' 39 | for s in list('abcde'): 40 | sel = q._asdict()[s] 41 | if sel: 42 | md += '{}. {}\n'.format(s.upper(), 43 | (cipher.decrypt(sel) if cipher else sel).strip()) 44 | md += '```\n' 45 | qid += 1 46 | with open('output/{}.md'.format(course), 'w') as f: 47 | f.write(md) 48 | 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /QZoneCrawl/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | .idea/ 3 | .DS_Store 4 | output/* 5 | images/ 6 | /*.png 7 | *.log 8 | *.docx 9 | -------------------------------------------------------------------------------- /QZoneCrawl/QZoneCrawl.py: -------------------------------------------------------------------------------- 1 | from selenium import webdriver 2 | from selenium.webdriver.common.by import By 3 | from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0 4 | from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0 5 | from selenium.webdriver.common.desired_capabilities import DesiredCapabilities 6 | from selenium.common.exceptions import TimeoutException, NoSuchElementException, \ 7 | StaleElementReferenceException, WebDriverException, ElementNotVisibleException 8 | from PIL import Image 9 | from pyzbar import pyzbar 10 | from urllib.request import urlretrieve 11 | from urllib.error import URLError 12 | from functools import wraps 13 | import qrcode, hashlib, os 14 | import socket 15 | from datetime import datetime 16 | import pypandoc 17 | 18 | 19 | class QZoneCrawl: 20 | url = "https://xui.ptlogin2.qq.com/cgi-bin/xlogin?proxy_url=https%3A//qzs.qq.com/qzone/v6/portal/proxy.html&daid" \ 21 | "=5&&hide_title_bar=1&low_login=0&qlogin_auto_login=1&no_verifyimg=1&link_target=blank&appid=549000912" \ 22 | "&style=22&target=self&s_url=https%3A%2F%2Fqzs.qzone.qq.com%2Fqzone%2Fv5%2Floginsucc.html%3Fpara%3Dizone" \ 23 | "%26from%3Diqq&pt_qr_app=手机QQ空间&pt_qr_link=http%3A//z.qzone.com/download.html&self_regurl=https%3A//qzs.qq" \ 24 | ".com/qzone/v6/reg/index.html&pt_qr_help_link=http%3A//z.qzone.com/download.html&pt_no_auth=0 " 25 | 26 | def __init__(self, qq, timeout=20, save_images=True, driver='Phantomjs'): 27 | socket.setdefaulttimeout(timeout) 28 | self.qq = qq 29 | self.__login = False 30 | self.save_images = save_images 31 | self.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) ' \ 32 | 'Chrome/61.0.3163.100 Safari/537.36 ' 33 | self.md = "此({})动态由https://github.com/netcan/QZoneCrawler于{}采集备份,欢迎Star/交流学习,禁止商用。\n\n" 34 | if driver == 'Phantomjs': 35 | opt = dict(DesiredCapabilities.PHANTOMJS) 36 | opt["phantomjs.page.settings.userAgent"] = self.userAgent 37 | self.driver = webdriver.PhantomJS(desired_capabilities=opt) 38 | else: 39 | opt = webdriver.ChromeOptions() 40 | opt.add_argument("user-agent=" + self.userAgent) 41 | self.driver = webdriver.Chrome(chrome_options=opt) 42 | 43 | def write_md(feed_info): 44 | @wraps(feed_info) 45 | def wrapper(self, *args, **kwargs): 46 | feed_ifo = feed_info(self, *args, **kwargs) 47 | self.md += '### ' + feed_ifo['time'] + '\n' 48 | if feed_ifo['content']: 49 | self.md += '```' + \ 50 | feed_ifo['content'] + \ 51 | '```\n\n' 52 | for url in feed_ifo['images']: 53 | filename = 'images/' + hashlib.sha256(url.encode()).hexdigest() 54 | self.md += '![]({})\n'.format(filename) 55 | 56 | self.md += '\n***\n\n' 57 | print(feed_ifo['content']) 58 | return wrapper 59 | 60 | @write_md 61 | def feed_info(self, feed): 62 | if not os.path.exists('images'): 63 | os.mkdir('images') 64 | 65 | feed_ifo = {'content': feed.find_element_by_css_selector('div.bd > pre').text, 66 | 'time': feed.find_element_by_css_selector('.goDetail').get_attribute('title'), 67 | 'images': []} 68 | # 保存图片 69 | if self.save_images: 70 | try: 71 | imgs = feed.find_elements_by_css_selector('.img-attachments-inner.clearfix > a') 72 | except StaleElementReferenceException: 73 | imgs = None 74 | for img in imgs: 75 | url = img.get_attribute('href') 76 | feed_ifo['images'].append(url) 77 | filename = 'images/' + hashlib.sha256(url.encode()).hexdigest() 78 | if url.startswith('http') and not os.path.exists(filename): 79 | try: 80 | urlretrieve(url, filename) 81 | except (URLError, TimeoutError, socket.timeout): 82 | pass 83 | return feed_ifo 84 | 85 | def login(self): 86 | # 扫描二维码,跳转到个人主页的说说页面 87 | self.driver.get(QZoneCrawl.url) 88 | self.driver.save_screenshot('qrcode.png') 89 | code = pyzbar.decode(Image.open('qrcode.png'))[0].data 90 | qrcode.make(code).save('qrcode.png') 91 | 92 | print('请扫描二维码登陆:./qrcode.png') 93 | try: 94 | WebDriverWait(self.driver, 600).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#pageContent'))) 95 | except TimeoutException: 96 | print('登陆失败!') 97 | self.quit() 98 | else: 99 | print('登陆成功!') 100 | self.__login = True 101 | 102 | def login_required(crawl): 103 | @wraps(crawl) 104 | def wrapper(self, *args, **kwargs): 105 | if not self.__login: 106 | self.login() 107 | crawl(self, *args, **kwargs) 108 | return wrapper 109 | 110 | @login_required 111 | def crawl(self, start_page=1, callback=None): 112 | # 跳转到说说页面 113 | print("当前抓取对象:", self.qq) 114 | self.driver.get('https://user.qzone.qq.com/{}/311'.format(self.qq)) 115 | WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#app_canvas_frame'))) 116 | # 获取最大页码数量 117 | self.driver.switch_to.default_content() 118 | self.driver.switch_to.frame('app_canvas_frame') 119 | WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, 120 | 'div.box.bgr3 div.bd > pre'))) 121 | 122 | while True: 123 | try: 124 | feed_pages = int(self.driver.find_element_by_css_selector('a[id^="pager_last"]').text) 125 | self.driver.find_element_by_css_selector('input[id^="pager_go"]').clear() 126 | if start_page != 1: 127 | self.driver.find_element_by_css_selector('input[id^="pager_go"]').send_keys(start_page) 128 | self.driver.find_element_by_css_selector('button[id^="pager_gobtn"]').click() 129 | lst_feeds = self.driver.find_elements_by_css_selector('div.box.bgr3') 130 | cur_page = int(self.driver.find_element_by_css_selector('p span.current').text) 131 | except (NoSuchElementException, WebDriverException): 132 | self.driver.implicitly_wait(1) 133 | continue 134 | else: 135 | if cur_page == start_page: 136 | break 137 | 138 | # 开始爬取说说 139 | feed_num = 0 140 | # print(feed_pages) 141 | while cur_page <= feed_pages: # <=2调试用 142 | print("page:", cur_page, '/', feed_pages) 143 | cur_feeds = self.driver.find_elements_by_css_selector('div.box.bgr3') 144 | # 刷新当前页面的说说 145 | while cur_feeds == lst_feeds and cur_page != 1: 146 | self.driver.implicitly_wait(1) 147 | cur_feeds = self.driver.find_elements_by_css_selector('div.box.bgr3') 148 | 149 | # 动态封存,跳出 150 | try: 151 | if self.driver.find_element_by_css_selector('img.empty_pic_message'): 152 | print('动态无法读取,可能已封存,跳出中...') 153 | break 154 | except NoSuchElementException: 155 | pass 156 | 157 | # 展开说说 158 | # more = self.driver.find_elements_by_css_selector('div.bd > div.f_toggle > a.has_more_con') 159 | # for m in more: 160 | # if m.text == '展开查看全文': 161 | # m.click() 162 | 163 | for feed in cur_feeds: 164 | print(feed_num) 165 | callback(feed) if callback else \ 166 | print(feed.find_element_by_css_selector('div.bd > pre').text) 167 | feed_num += 1 168 | 169 | # 翻页 170 | lst_page = cur_page 171 | if lst_page == feed_pages: 172 | break 173 | while True: 174 | try: 175 | WebDriverWait(self.driver, 1).until(EC.presence_of_element_located((By.CSS_SELECTOR, 176 | r'a[id^="pager_next"]'))) 177 | self.driver.find_element_by_css_selector(r'a[id^="pager_next"]').click() 178 | cur_page = int(self.driver.find_element_by_css_selector('p span.current').text) 179 | except (StaleElementReferenceException, WebDriverException): 180 | self.driver.implicitly_wait(1) 181 | continue 182 | else: 183 | if lst_page != cur_page: 184 | break 185 | 186 | WebDriverWait(self.driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, 187 | 'div.box.bgr3 div.bd > pre'))) 188 | lst_feeds = cur_feeds 189 | 190 | def save_feeds(self, fmt='epub'): 191 | if not os.path.exists('output'): 192 | os.mkdir('output') 193 | 194 | if self.md: 195 | pypandoc.convert_text(self.md.format(self.qq, datetime.now().strftime('%F %T')), fmt, 196 | 'markdown', outputfile='output/{}.{}'.format(self.qq, fmt)) 197 | # self.md = str() 198 | 199 | def quit(self): 200 | self.driver.quit() 201 | 202 | -------------------------------------------------------------------------------- /QZoneCrawl/README.md: -------------------------------------------------------------------------------- 1 | # QZoneCrawler 2 | QQ空间爬虫,完善中... 3 | 4 | ## 依赖库 5 | - [PhantomJS](http://phantomjs.org/download.html) 6 | - [Chrome driver](https://sites.google.com/a/chromium.org/chromedriver/downloads) 7 | ``` 8 | $ apt-get install libzbar0, pandoc 9 | $ pip install selenium 10 | $ pip install pillow 11 | $ pip install pyzbar 12 | $ pip install qrcode 13 | $ pip install pypandoc 14 | ``` 15 | 16 | ## 运行 17 | ```python 18 | In [64]: qzone = QZoneCrawl.QZoneCrawl(1980337171, timeout=30) 19 | 20 | In [65]: qzone.crawl(1, qzone.feed_info) 21 | 请扫描二维码登陆:./qrcode.png 22 | 登陆成功! 23 | 当前抓取对象: 1980337171 24 | page: 1 / 27 25 | 0 26 | 【小创五岁啦~(*´▽`*)】 27 | 小创今天收到了好多好多童鞋的生日祝福和礼物,真的是超级开心超级感动啊五年陪伴,接下来小创一定会更加努力地帮助同学们,为大家服务哒~(`•ω•´)ゞ 28 | 最后,新的一岁的愿望是—— 29 | 变成更好的小创!\( ̄︶ ̄)/ 30 | 1 31 | 【失物招领】 32 | To 一个妹子 33 | 你在交双百大赛作品时,把U盘落在行政楼114王老师那里了,小创提醒你快去拿哦~(∗❛ั∀❛ั∗)✧*。 34 | 2 35 | 【庆祝第五届ACM程序设计大赛圆满成功】 36 | 早早开始报名,又推迟举办日期,这样的比赛是不是有些千呼万唤始出来的感觉呢?没错,ACM程序设计大赛就是这样一个令人期待的比赛,今天它终于圆满结束了,小创在这里感谢童鞋们的参与。 37 | 比赛一开始,紧张的气氛便充满了赛场。面对十一道程序设计题目的 刁难,选手们经受住了考验。经过五个小时的奋斗,共有52名同学在比赛中获奖,你们真的很棒棒喔 。没有获奖同学,小创同样要为你们的积极参与点赞。 38 | 五彩缤纷的气球夺人眼球,紧张激烈的气氛扣人心弦,这就是ACM程序设计大赛。下届比赛,小创依旧与你们相约。 39 | ... 40 | 41 | In [66]: qzone.save_feeds() 42 | ``` 43 | 44 | ## 效果图 45 | ![log](screenshots/log.png) 46 | 47 | ![feeds](screenshots/feeds.png) 48 | 49 | -------------------------------------------------------------------------------- /QZoneCrawl/screenshots/feeds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netcan/MyCrawler/2cf63c7282ac6438f64ca2e5ca62770df7e639cf/QZoneCrawl/screenshots/feeds.png -------------------------------------------------------------------------------- /QZoneCrawl/screenshots/log.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/netcan/MyCrawler/2cf63c7282ac6438f64ca2e5ca62770df7e639cf/QZoneCrawl/screenshots/log.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MyCrawler 2 | 我的爬虫合集 3 | 4 | - QQ空间爬虫 5 | - 合肥工业大学思政题库爬虫 6 | -------------------------------------------------------------------------------- /Shanbay/elevator.py: -------------------------------------------------------------------------------- 1 | from login import login 2 | 3 | import json, re 4 | import requests 5 | 6 | 7 | class Elevator: 8 | # 扇贝阶梯训练 9 | api = 'https://www.shanbay.com/api/v2/elevator' 10 | rest_url = 'https://rest.shanbay.com/api/v2/elevator' 11 | login_url = 'https://rest.shanbay.com/api/v1/account/login' 12 | user_agent = 'bayAgent/1.1 Android/5.1.1 com.shanbay.words/7.9.120 tencent-channel/0 HUAWEI/HUAWEI_M2-A01W ' \ 13 | 'frontend/1.8 api/2.3 ' 14 | 15 | def __init__(self, username, password): 16 | self.session = login(username, password) 17 | assert isinstance(self.session, requests.sessions.Session), '登陆失败!' 18 | 19 | def grammar(self): 20 | """ 21 | 爬取阶梯训练语法部分 22 | :return: 23 | """ 24 | assert isinstance(self.session, requests.sessions.Session), '登陆失败!' 25 | grammar_lists = json.loads(self.session.get(Elevator.api + '/parts/bclhtz/stages/').text)['data'] 26 | with open('grammar.md', 'w') as f: 27 | for idx, section in enumerate(grammar_lists): 28 | if idx >= 46: 29 | break 30 | content = json.loads(self.session.get(self.rest_url + '/tasks/{}/'.format(section['object_id'])).text)['data'] 31 | # print('=====================') 32 | # print(idx, section['title']) 33 | try: 34 | if content['knowledge'] or content['intro']: 35 | f.write('# ' + section['title'] + '\n') 36 | f.write(re.sub('\d\.', '##', re.sub('\d\.\d', '###', content['intro'])) + '\n\n') 37 | f.write(re.sub('\d\.', '##', re.sub('\d\.\d', '###', content['knowledge'])) + '\n\n') 38 | # print(content['intro']) 39 | # print(content['knowledge']) 40 | except KeyError: 41 | pass 42 | 43 | 44 | -------------------------------------------------------------------------------- /Shanbay/grammar.md: -------------------------------------------------------------------------------- 1 | Table of Contents 2 | ================= 3 | 4 | * [主谓结构](#主谓结构) 5 | * [谓语动词的特点](#谓语动词的特点) 6 | * [简单句叠加成复杂难句](#简单句叠加成复杂难句) 7 | * [主谓宾结构](#主谓宾结构) 8 | * [谓语动词的特点](#谓语动词的特点-1) 9 | * [简单句叠加成复杂难句](#简单句叠加成复杂难句-1) 10 | * [非谓语动词作主语1](#非谓语动词作主语1) 11 | * [动词不定式的基本概念](#动词不定式的基本概念) 12 | * [动名词的基本概念](#动名词的基本概念) 13 | * [动词不定式(to do)作主语](#动词不定式to-do作主语) 14 | * [放在句首作主语](#放在句首作主语) 15 | * [放在句末作主语](#放在句末作主语) 16 | * [动名词-ing作主语](#动名词-ing作主语) 17 | * [放在句首作主语](#放在句首作主语-1) 18 | * [放在句末作主语](#放在句末作主语-1) 19 | * [动词不定式(to do)和动名词-ing在表示动作和时间等方面的差别](#动词不定式to-do和动名词-ing在表示动作和时间等方面的差别) 20 | * [非谓语动词作主语2](#非谓语动词作主语2) 21 | * [非谓语动词作宾语1](#非谓语动词作宾语1) 22 | * [常见的需要接动词不定式(to do)作宾语的动词](#常见的需要接动词不定式to-do作宾语的动词) 23 | * [常见的需要接动名词-ing作宾语的动词](#常见的需要接动名词-ing作宾语的动词) 24 | * [非谓语动词作宾语2](#非谓语动词作宾语2) 25 | * [“动词+疑问词+to do”结构](#动词疑问词to-do结构) 26 | * [动名词-ing作介词宾语](#动名词-ing作介词宾语) 27 | * [to后面接动名词-ing还是接动词原形do](#to后面接动名词-ing还是接动词原形do) 28 | * [主谓双宾结构](#主谓双宾结构) 29 | * [谓语动词的特点](#谓语动词的特点-2) 30 | * [简单句叠加成复杂难句](#简单句叠加成复杂难句-2) 31 | * [主谓宾宾补结构](#主谓宾宾补结构) 32 | * [谓语动词的特点](#谓语动词的特点-3) 33 | * [简单句叠加成复杂难句](#简单句叠加成复杂难句-3) 34 | * [如何区分双宾语和复合宾语](#如何区分双宾语和复合宾语) 35 | * [“主谓宾宾补”结构的一种特殊用法](#主谓宾宾补结构的一种特殊用法) 36 | * [非谓语动词作宾语补足语1](#非谓语动词作宾语补足语1) 37 | * [常见的需要接动词不定式(to do)作宾语补足语的动词](#常见的需要接动词不定式to-do作宾语补足语的动词) 38 | * [常见的需要接不带to的动词不定式作宾语补足语的动词](#常见的需要接不带to的动词不定式作宾语补足语的动词) 39 | * [常见的需要接分词作宾语补足语的动词](#常见的需要接分词作宾语补足语的动词) 40 | * [分词的基本概念](#分词的基本概念) 41 | * [分词作宾语补足语](#分词作宾语补足语) 42 | * [非谓语动词作宾语补足语2](#非谓语动词作宾语补足语2) 43 | * [主系表结构](#主系表结构) 44 | * [谓语动词的特点](#谓语动词的特点-4) 45 | * [简单句叠加成复杂难句](#简单句叠加成复杂难句-4) 46 | * [非谓语动词作表语](#非谓语动词作表语) 47 | * [一般时态](#一般时态) 48 | * [一般现在时](#一般现在时) 49 | * [构成](#构成) 50 | * [功能](#功能) 51 | * [常见时间状语标志](#常见时间状语标志) 52 | * [一般过去时](#一般过去时) 53 | * [构成](#构成-1) 54 | * [功能](#功能-1) 55 | * [常见时间状语标志](#常见时间状语标志-1) 56 | * [一般将来时](#一般将来时) 57 | * [构成](#构成-2) 58 | * [功能](#功能-2) 59 | * [常见时间状语标志](#常见时间状语标志-2) 60 | * [其它结构及其用法](#其它结构及其用法) 61 | * [进行时态](#进行时态) 62 | * [现在进行时](#现在进行时) 63 | * [构成](#构成-3) 64 | * [功能](#功能-3) 65 | * [常见时间状语标志](#常见时间状语标志-3) 66 | * [过去进行时](#过去进行时) 67 | * [构成](#构成-4) 68 | * [功能](#功能-4) 69 | * [常见时间状语标志](#常见时间状语标志-4) 70 | * [进行时态其它用法](#进行时态其它用法) 71 | * [进行时态用法注意事项](#进行时态用法注意事项) 72 | * [进行时态与一般时态的用法比较](#进行时态与一般时态的用法比较) 73 | * [完成(进行)时态](#完成进行时态) 74 | * [现在完成时](#现在完成时) 75 | * [构成](#构成-5) 76 | * [功能](#功能-5) 77 | * [常见时间状语标志](#常见时间状语标志-5) 78 | * [过去完成时](#过去完成时) 79 | * [构成](#构成-6) 80 | * [功能](#功能-6) 81 | * [常见时间状语标志](#常见时间状语标志-6) 82 | * [现在完成进行时](#现在完成进行时) 83 | * [构成](#构成-7) 84 | * [功能](#功能-7) 85 | * [常见时间状语标志](#常见时间状语标志-7) 86 | * [完成时态用法注意事项](#完成时态用法注意事项) 87 | * [被动语态](#被动语态) 88 | * [被动语态的构成](#被动语态的构成) 89 | * [被动语态的使用要点](#被动语态的使用要点) 90 | * [被动语态的使用范围](#被动语态的使用范围) 91 | * [主谓一致1](#主谓一致1) 92 | * [主谓一致2](#主谓一致2) 93 | * [FANBOYS](#fanboys) 94 | * [for表示原因或理由(“因为”)](#for表示原因或理由因为) 95 | * [and表示平行、顺接、递进等](#and表示平行顺接递进等) 96 | * [nor用于否定句后,引出另一否定句以补充前句(“也不”)](#nor用于否定句后引出另一否定句以补充前句也不) 97 | * [but和yet表示转折或对照(“但是;然而”)](#but和yet表示转折或对照但是然而) 98 | * [or表示选择(“或者;不然的话”)](#or表示选择或者不然的话) 99 | * [so表示结果(“所以”)](#so表示结果所以) 100 | * [其它常见的并列连词:while和whereas表示对比(“而”)](#其它常见的并列连词while和whereas表示对比而) 101 | * [并列连词用法注意事项](#并列连词用法注意事项) 102 | * [连接副词1](#连接副词1) 103 | * [连接副词2](#连接副词2) 104 | * [连接副词3](#连接副词3) 105 | * [句子的正确连接](#句子的正确连接) 106 | * [识别名词性从句](#识别名词性从句) 107 | * [主语从句](#主语从句) 108 | * [引导名词性从句的连接词](#引导名词性从句的连接词) 109 | * [主语从句的相关用法](#主语从句的相关用法) 110 | * [that引导的主语从句](#that引导的主语从句) 111 | * [其它连接词引导的主语从句](#其它连接词引导的主语从句) 112 | * [宾语从句](#宾语从句) 113 | * [动词的宾语从句](#动词的宾语从句) 114 | * [介词的宾语从句](#介词的宾语从句) 115 | * [表语从句](#表语从句) 116 | * [that引导的表语从句](#that引导的表语从句) 117 | * [其它连接词引导的表语从句](#其它连接词引导的表语从句) 118 | * [同位语从句](#同位语从句) 119 | * [that引导的同位语从句](#that引导的同位语从句) 120 | * [其它连接词引导的同位语从句](#其它连接词引导的同位语从句) 121 | * [非谓语动词作定语1](#非谓语动词作定语1) 122 | * [动词不定式作定语](#动词不定式作定语) 123 | * [动名词作定语](#动名词作定语) 124 | * [分词作定语](#分词作定语) 125 | * [非谓语动词作定语2](#非谓语动词作定语2) 126 | * [动词不定式作定语](#动词不定式作定语-1) 127 | * [动名词作定语](#动名词作定语-1) 128 | * [分词作定语](#分词作定语-1) 129 | * [关系代词1](#关系代词1) 130 | * [定语从句的基本概念](#定语从句的基本概念) 131 | * [引导定语从句的关系代词](#引导定语从句的关系代词) 132 | * [关系代词2](#关系代词2) 133 | * [定语从句中的主谓一致](#定语从句中的主谓一致) 134 | * [关系代词的省略](#关系代词的省略) 135 | * [关系副词](#关系副词) 136 | * [关系副词的基本用法](#关系副词的基本用法) 137 | * [关系副词用法注意事项](#关系副词用法注意事项) 138 | * [how不能用来引导定语从句](#how不能用来引导定语从句) 139 | * [限制性VS非限制性](#限制性vs非限制性) 140 | * [限制性定语从句的基本概念](#限制性定语从句的基本概念) 141 | * [非限制性定语从句的基本概念](#非限制性定语从句的基本概念) 142 | * [非限制性定语从句的用法要点](#非限制性定语从句的用法要点) 143 | * [非限制性定语从句用法注意事项](#非限制性定语从句用法注意事项) 144 | * [非谓语动词作状语1](#非谓语动词作状语1) 145 | * [非谓语动词作状语2](#非谓语动词作状语2) 146 | * [时间、地点状语从句](#时间地点状语从句) 147 | * [时间状语从句](#时间状语从句) 148 | * [when、while和as](#whenwhile和as) 149 | * [before和after](#before和after) 150 | * [until](#until) 151 | * [since](#since) 152 | * [其它连接词](#其它连接词) 153 | * [地点状语从句](#地点状语从句) 154 | * [注意事项](#注意事项) 155 | * [原因、方式状语从句](#原因方式状语从句) 156 | * [原因状语从句](#原因状语从句) 157 | * [because、since和as](#becausesince和as) 158 | * [介词短语表示因果关系](#介词短语表示因果关系) 159 | * [其它连接词](#其它连接词-1) 160 | * [方式状语从句](#方式状语从句) 161 | * [as和just as](#as和just-as) 162 | * [as if和as though](#as-if和as-though) 163 | * [条件、让步状语从句](#条件让步状语从句) 164 | * [条件状语从句](#条件状语从句) 165 | * [if和unless](#if和unless) 166 | * [其它连接词](#其它连接词-2) 167 | * [让步状语从句](#让步状语从句) 168 | * [though、although、even if和even though](#thoughalthougheven-if和even-though) 169 | * [despite和in spite of](#despite和in-spite-of) 170 | * [while和whereas](#while和whereas) 171 | * [whatever、whenever、wherever、whoever、whichever和however](#whateverwheneverwhereverwhoeverwhichever和however) 172 | * [注意事项](#注意事项-1) 173 | * [目的、结果、比较状语从句](#目的结果比较状语从句) 174 | * [目的状语从句](#目的状语从句) 175 | * [so that和in order that](#so-that和in-order-that) 176 | * [lest、in case和for fear that](#lestin-case和for-fear-that) 177 | * [结果状语从句](#结果状语从句) 178 | * [so that](#so-that) 179 | * [so... that和such... that](#so-that和such-that) 180 | * [比较状语从句](#比较状语从句) 181 | * [连词as的基本用法](#连词as的基本用法) 182 | * [连词than的基本用法](#连词than的基本用法) 183 | * [表示倍数比较的三种句型](#表示倍数比较的三种句型) 184 | * [“the more..., the more”句型](#the-more-the-more句型) 185 | 186 | # 主谓结构 187 | 各位同学,大家好!欢迎来到四级语法阶梯训练! 188 | 189 | 在阶梯训练的前两个阶段中,我们将重点围绕简单句的五种基本句型进行展开,为分析长难句、写好复杂句打下一个良好的基础。 190 | 191 | 本次训练,我们首先来学习简单句的第一种基本句型,即“主谓”结构。 192 | 193 | ## 谓语动词的特点 194 | 在“主谓”结构中,谓语动词是不及物动词。 195 | 这种动词所表示的动作没有作用对象,其本身的意思完整,其后不需带宾语。 196 | 197 | 例句: 198 | He died. 199 | 【die这个动作是主语自主完成的,并没有作用对象,所以后面不能再接宾语】 200 | 参考译句:他死了。 201 | 202 | 此结构中的谓语动词的后面虽然不接宾语,但通常会接副词或介词短语来说明动词的方式、地点或时间等等,这种修饰动作的成分被称之为状语。 203 | 204 | 例句: 205 | All the students study hard at school. 206 | 【“hard”是副词、“at school”是介词短语,分别用于说明“study”这一动作的方式和发生的地点】 207 | 参考译句:所有学生在学校都努力学习。 208 | 209 | ## 简单句叠加成复杂难句 210 | 211 | 例句1: 212 | This trend began. 213 | 【主语是this trend;谓语是不及物动词began,后面没有再接宾语】 214 | 参考译句:这种趋势开始了。 215 | 216 | 例句2: 217 | This trend began during the Second World War, a global war lasting from 1939 to 1945 and involving the vast majority of the world’s countries—including all of the great powers. 218 | 【介词短语“during the Second World War”作时间状语,说明“begin”这一动作发生的时间,整个“a global war...”部分用于对“the Second World War”这一专有名词作进一步解释】 219 | 参考译句:这种趋势始于第二次世界大战期间,这场全球性的战争从1939年一直持续到1945年,世界上的绝大多数国家(包括所有的大国在内)都参与其中。 220 | 221 | 比较上面两个例句不难发现,第二个句子要比第一个句子复杂得多,但是基本句型并没有改变,其核心依然是“this trend began”这一“主谓”结构。 222 | 223 | # 主谓宾结构 224 | 在上次训练中,我们学习了“主谓”结构这一简单句的基本句型。 225 | 226 | 本次训练,我们来学习一下简单句的另一种基本句型,即“主谓宾”结构。 227 | 228 | ## 谓语动词的特点 229 | 在“主谓宾”结构中,谓语动词是及物动词。 230 | 这种动词告诉我们由主语发出的动作所作用的对象是什么,这个“所作用的对象”就是通常所说的宾语,即宾语是主语动作的承受对象,因此这类动词是带有宾语的。 231 | 232 | 例句1: 233 | They are playing football. 234 | 【football是play这一动作的作用对象,是宾语,即“他们在玩什么”】 235 | 参考译句:他们正在踢足球。 236 | 237 | 例句2: 238 | Today, some foreigners speak Chinese well. 239 | 【句首的today作时间状语,句末的well作方式状语】 240 | 参考译句:如今,一些外国人汉语说得很好。 241 | 242 | 例句3: 243 | The boy loves the girl deeply. 244 | 参考译句:这个男孩深爱着那个女孩。 245 | 246 | 由以上例句可以看出,在句中充当主语和宾语的通常是名词和代词。另外,和“主谓”结构类似,在“主谓宾”结构中,宾语后面也可以接副词或介词短语作状语,对谓语动词进行修饰。 247 | 248 | 据统计,英语中大约80%的句子是“主谓宾”结构,可见其使用频率之高,因此更要将其掌握好。 249 | 250 | ## 简单句叠加成复杂难句 251 | 252 | 例句1: 253 | The emphasis ignored the great importance. 254 | 【主语是the emphasis;谓语是及物动词ignored,宾语是the great importance】 255 | 参考译句:这种强调忽视了这一重要性。 256 | 257 | 例句2: 258 | The emphasis by both scholars and statesmen to the disappearance of the American frontier ignored the great importance of changes in the consequences of international trade. 259 | 【介词短语“by both scholars and statesmen”表明“谁在强调”, 介词短语“to the disappearance of the American frontier”说明主语emphasis的具体内容,介词短语“of changes in the consequences of international trade”说明宾语importance的具体内容】 260 | 参考译句:学者和政治家们强调美国边疆的消失,这种强调忽视了国际贸易的后果带来的变化的巨大作用。 261 | 262 | 比较上面两个例句不难发现,第二个句子要比第一个句子复杂得多,但是基本句型并没有改变,其核心依然是“the emphasis ignored the great importance”这一“主谓宾”结构。 263 | 264 | # 非谓语动词作主语1 265 | 在之前的两次训练中,我们先后学习了“主谓”和“主谓宾”这两种句型结构,知道主语一般是由名词和代词来充当的。在接下来的两次训练中,我们将会学习非谓语动词作主语的相关用法。 266 | 267 | 非谓语动词一共有三种形式,分别是动词不定式、动名词以及分词。其中,动词不定式和动名词可以作主语,但是它们的具体使用情况却不尽相同。 268 | 269 | 本次训练,我们首先来学习一下动词不定式和动名词作主语的基本用法,而关于分词的用法则会在之后的训练中再作专门讲解。 270 | 271 | ## 动词不定式的基本概念 272 | 动词不定式是非谓语动词三种形式之一,由“to+动词原形”构成,在句中可以起到名词、形容词或副词的作用,同时也保留了动词的一些特征。 273 | 274 | ## 动名词的基本概念 275 | 动名词是非谓语动词三种形式之一,由“动词原形+-ing”构成。动名词兼有动词以及名词的特征和作用。 276 | 277 | ## 动词不定式(to do)作主语 278 | ### 放在句首作主语 279 | 在英语中,动词不定式(to do)直接放在句首作主语的情况是不常见的。只有在一些比较特殊的情况下(比如:用于某些固定说法,或构成某种对比关系),才直接将其放在句首作主语。 280 | 281 | 例句: 282 | To respect others is to be respected.【对比】 283 | 参考译句:尊重别人就是尊重自己。 284 | 285 | ### 放在句末作主语 286 | 在英语中,动词不定式(to do)作主语时,往往由it代替它作形式主语,放在句首,而将真正的主语动词不定式(to do)移至句末,从而构成“It+to do”这样的句型,具体有以下几类: 287 | 1)It is+形容词+to do 288 | 2)It is+名词+to do 289 | 3)It+其它结构+to do 290 | 291 | 例句1: 292 | It would be wrong to marry for money.【wrong是形容词】 293 | 参考译句:为钱而结婚是错误的。 294 | 295 | 例句2: 296 | It is a virtue to admit one’s own shortcomings.【virtue是名词】 297 | 参考译句:正视自己的缺点是一种美德。 298 | 299 | 例句3: 300 | It takes time and effort to master English.【take time and effort是“动词+宾语”结构】 301 | 参考译句:要掌握英语得花费时间、付出努力。 302 | 303 | ## 动名词-ing作主语 304 | ### 放在句首作主语 305 | 与动词不定式(to do)作主语不同,动名词-ing作主语一般直接放在句首。 306 | 307 | 例句: 308 | Getting up early is considered a good habit. 309 | 参考译句:早起被认为是一种好习惯。 310 | 311 | ### 放在句末作主语 312 | 在英语中,只有在某些特定的句型中才会出现把动名词-ing放在句末作主语的情况。 313 | 314 | 例句1: 315 | It’s no use waiting here.【固定句型:It is no use doing...】 316 | 参考译句:在这里等没用。 317 | 318 | 例句2: 319 | There is now no turning back.【固定句型:There is no doing...】 320 | 参考译句:现在只有前进,没有退路。 321 | 322 | ## 动词不定式(to do)和动名词-ing在表示动作和时间等方面的差别 323 | 一般说来,动词不定式(to do)表示具体的或特定的动作,或是将来的动作;动名词-ing则表示一般习惯、抽象概念,时间概念不强,不是某一次动作。 324 | 325 | 例句比较: 326 | To lie is wrong.【对于执行者是谁,心目中是有所指的】 327 | Lying is wrong.【泛指这种做法、作风】 328 | 329 | # 非谓语动词作主语2 330 | 在上次训练中,我们学习了动词不定式(to do)和动名词-ing作主语的相关用法,知道动名词-ing作主语通常放在句首,而动词不定式(to do)作主语则多位于句末。 331 | 332 | 本次训练,我们一方面会复习巩固上次训练中学过的语法点,另一方面对于“It+to do”这一句型会作两点补充说明。 333 | 334 | 关于“It+to do”句型的两点补充说明 335 | 1)“It is+形容词+X+代词/名词+to do”中的X用of还是用for 336 | 337 | 表示人物特征的形容词常同of搭配,构成“It is+形容词+of+代词/名词+to do”这一句型, 338 | 这类形容词同of后的代词或名词关系密切,有意义上的主表关系。 339 | 340 | 例句: 341 | It was generous of her to lend me so much money.【形容词generous表示人物特征】 342 | = She was generous to lend me so much money.【she和generous是主语和表语的关系】 343 | 参考译句:她很慷慨,借给了我这么多钱。 344 | 345 | 表示事物性质的形容词常同for搭配,构成“It is+形容词+for+代词/名词+to do”这一句型, 346 | 这类形容词与句中的不定式结构关系密切,有意义上的主表关系。 347 | 348 | 例句: 349 | It is hard for him to get rid of his bad habit.【形容词hard表示事物性质】 350 | = For him to get rid of his bad habit is hard.【to get rid of...和hard是主语和表语的关系】 351 | 参考译句:他很难改掉坏习惯。 352 | 353 | 2)汉英思维差异:不可以说“I am impossible to do it.” 354 | 355 | 错误的句子: 356 | We are impossible to master English in a short time. 357 | 错误原因分析: 358 | 汉语中可以说“我们不可能……”,但英语中不能说“We are impossible...”,因为“impossible”一词是表示事物性质的形容词,在英语中不能修饰“人”,而只能说明“事情”。 359 | 360 | 正确的句子: 361 | It is impossible for us to master English in a short time. 362 | 参考译句:我们不可能在很短的时间内就掌握英语。 363 | 364 | 用法总结: 365 | 有些(表示事物性质的)形容词通常不可用于“人称代词+be+形容词+to do”这一句型,常见的有以下一些: 366 | easy, hard, difficult, urgent, necessary, convenient, dangerous, impossible等 367 | 368 | 错误的句子: 369 | I am hard / difficult / necessary / urgent to convince her. 370 | 正确的句子: 371 | It is hard / difficult / necessary / urgent for me to convince her. 372 | 373 | # 非谓语动词作宾语1 374 | 在之前的两次训练中,我们学习了非谓语动词作主语的相关用法。在接下来的两次训练中,我们再来学习一下非谓语动词作宾语的相关用法。 375 | 376 | 动词不定式(to do)、动名词-ing这两种非谓语动词形式不仅可以作主语,还可以作宾语,但是它们的具体使用情况却不尽相同。 377 | 378 | 本次训练,我们将围绕一些常见的动词进行展开,看一看到底哪些动词后面需要用动词不定式作宾语,哪些动词后面又需要跟动名词作宾语,这其中有很多是需要记忆的内容。 379 | 380 | ## 常见的需要接动词不定式(to do)作宾语的动词 381 | try, strive, attempt, want, tend, decide, expect, learn, hesitate, choose, fail, refuse, threaten, hope, appear, intend, afford, plan, manage等 382 | 383 | 例句: 384 | I can’t afford to take flying lessons. 385 | 参考译句:我付不起飞行课程的费用。 386 | 387 | ## 常见的需要接动名词-ing作宾语的动词 388 | appreciate, prohibit, discuss, mean, avoid, quit, suggest, consider, involve, postpone, enjoy, recommend, delay, risk, include等 389 | 390 | 例句: 391 | Peter suggested stopping at the next town. 392 | 参考译句:彼得建议在下一个小镇停下。 393 | 394 | # 非谓语动词作宾语2 395 | 在上次训练中,我们学习了一些常见的需要接动词不定式(to do)和动名词-ing作宾语的动词。 396 | 397 | 本次训练,我们将继续围绕非谓语动词作宾语这一语法点进行展开,重点学习一下另外两种比较特殊的用法。 398 | 399 | ## “动词+疑问词+to do”结构 400 | 在一些动词之后,可以在连接代词(what, who, which)、连接副词(how, when, where)以及连词(whether)后面接动词不定式(to do),此结构在本质上相当于连接词引导的宾语从句的简略形式。 401 | 402 | 例句1: 403 | I wonder who to invite. (= who I should invite) 404 | 参考译句:我想知道该邀请谁。 405 | 406 | 例句2: 407 | He quickly learned how to fly a kite. (= how he could fly a kite) 408 | 参考译句:他很快学会了如何放风筝。 409 | 410 | 例句3: 411 | I don’t know whether to answer his letter. (= whether I need to answer his letter) 412 | 参考译句:我不知道是否要给他回信。 413 | 414 | ## 动名词-ing作介词宾语 415 | 在介词后面不能直接用动词原形作宾语,必须将其改为动名词-ing。 416 | 417 | 例句: 418 | She left the room without saying a word more. 419 | 参考译句:她没再多说什么就离开了房间。 420 | 421 | ## to后面接动名词-ing还是接动词原形do 422 | to既可以是介词,也可以是动词不定式符号,在词组中容易混淆。若是介词,to后接动名词-ing;若是动词不定式符号,to后接接动词原形do。 423 | 424 | 常见的含有介词to、后接动名词-ing的词组 425 | in addition to, alternative / approach / solution to, lead to, contribute to, give rise to, dedicate / devote (sth. / oneself) to, look forward to, pay attention to, related to等 426 | 427 | 例句: 428 | I am looking forward to hearing from you. 429 | 参考译句:我期待你的来信。 430 | 431 | 432 | 433 | 434 | 435 | # 主谓双宾结构 436 | 在上一个阶段的训练中,我们已经学习了“主谓”结构和“主谓宾”结构这两种简单句的基本句型。 437 | 438 | 在这一阶段的训练中,我们将继续学习剩下的三种简单句的基本句型。 439 | 440 | 本次训练,我们首先来学习一下“主谓双宾”这一结构。 441 | 442 | ## 谓语动词的特点 443 | 在“主谓双宾”结构中,谓语动词是双宾动词。 444 | 这种动词后面所接的成分既有“人”又有“物”。一般来讲,这里的“人”表示动作的接受者,称作间接宾语;这里的“物”表示动作作用的对象,是动作的承受者,称作直接宾语。 445 | 间接宾语和直接宾语合起来称为“双宾语”。 446 | 447 | 例句1: 448 | He showed the guard his passport. 449 | 【指“人”的“the guard”是间接宾语,指“物”的“his passport”是直接宾语】 450 | 参考译句:他把护照给门卫看了。 451 | 452 | 例句2: 453 | Chatting online will bring you a lot of fun. 454 | 【指“人”的“you”是间接宾语,指“物”的“a lot of fun”是直接宾语】 455 | 参考译句:网上聊天会给你带来很多乐趣。 456 | 457 | 对于“主语+谓语+间接宾语+直接宾语”这一结构,通常可以进行这样的改写,即把直接宾语提前,放在谓语后面,然后添加介词to或for,再把间接宾语放在介词后面。 458 | 459 | 至于介词到底是选择to还是for,取决于谓语动词,具体如下: 460 | 1)对于show, bring, give, offer, send等动词,当间接宾语后移时,间接宾语前需带介词to 461 | 2)对于get, buy, find, keep, make等动词,当间接宾语后移时,间接宾语前需带介词for 462 | 463 | 例句1: 464 | I gave him my book. (= I gave my book to him.) 465 | 参考译句:我把我的书给他了。 466 | 467 | 例句2: 468 | I will buy you a meal. (= I will buy a meal for you.) 469 | 参考译句:我会请你吃顿饭。 470 | 471 | ## 简单句叠加成复杂难句 472 | 473 | 例句1: 474 | Her work won her the Nobel Prize. 475 | 【指“人”的“her”是间接宾语,指“物”的“the Nobel Prize”是直接宾语】 476 | 参考译句:她的工作使她赢得了诺贝尔奖。 477 | 478 | 例句2: 479 | Her work in genetics won United States scientist Barbara McClintock the Nobel Prize in 198## 480 | 【介词短语“in genetics”起修饰作用,用于说明主语“work”所属的领域,“United States scientist”这一部分用于补充说明间接宾语“Barbara McClintock”的身份信息,句末的“in 1983”作时间状语,说明“win”这一动作发生的时间】 481 | 参考译句:Barbara McClintock在遗传学领域的研究成果,使她赢得了1983年的诺贝尔奖。 482 | 483 | 比较上面两个例句不难发现,第二个句子要比第一个句子复杂一些,但是基本句型并没有改变,其核心依然是“her work won her the Nobel Prize”这一“主谓双宾”结构。 484 | 485 | # 主谓宾宾补结构 486 | 在上次训练中,我们学习了简单句五种基本句型中的“主谓双宾”结构。 487 | 488 | 本次训练,我们再来学习一种容易和“主谓双宾”结构混淆的简单句句型,即“主谓宾宾补”结构。 489 | 490 | ## 谓语动词的特点 491 | 在“主谓宾宾补”结构中,谓语动词是宾补动词。 492 | 这种动词后面接宾语,而此宾语后面又接补充说明宾语的补足语。宾语和宾语补足语合起来称为“复合宾语”。 493 | 常见的带复合宾语的动词有:let, call, feel, find, keep, make, leave, consider, believe等 494 | 495 | 例句1: 496 | I made John our chairman. 497 | 【“John”是宾语,“our chairman”是宾语补足语,补充说明宾语的情况,以使句子的意思完整】 498 | 参考译句:我选了约翰当我们的主席。 499 | 500 | 例句2: 501 | I found this answer wrong. 502 | 【“this answer”是宾语,“wrong”是宾语补足语,补充说明宾语的情况,以使句子的意思完整】 503 | 参考译句:我发现这个答案是错误的。 504 | 505 | 由以上例句可以看出,在句中充当宾语补足语的通常是形容词和名词。 506 | 507 | ## 简单句叠加成复杂难句 508 | 509 | 例句1: 510 | Willa Cather considered this novel her best work. 511 | 【谓语是宾补动词consider,其后不但要带宾语this novel,还要接宾语补足语her best work,补充说明前面的宾语,否则句子的意思不完整】 512 | 参考译句:Willa Cather认为这部小说是她最好的一部作品。 513 | 514 | 例句2: 515 | Willa Cather, a well-known American writer, considered her novel of life in nineteenth-century Nebraska, My Antonia, her best work. 516 | 【名词短语“a well-known American writer”用于补充说明主语Willa Cather的背景信息,介词短语“of life in nineteenth-century Nebraska, My Antonia”用于修饰宾语“her novel”,说明其具体信息】 517 | 参考译句:Willa Cather认为她的那部描写19世纪内布拉斯加州生活的小说《我的安东尼奥》是她最好的一部作品。 518 | 519 | 比较上面两个例句不难发现,第二个句子要比第一个句子复杂一些,但是基本句型并没有改变,其核心依然是“Willa Cather considered her novel her best work”这一“主谓宾宾补”结构。 520 | 521 | ## 如何区分双宾语和复合宾语 522 | 很多同学不能区分双宾语和复合宾语,尤其是当两者都是“动词+人+物”这样的结构时。 523 | 其实,区分这两种宾语的方法很简单,就是在宾语的后面加上be动词,若能构成一个语义通顺的句子,即是补足语,因为宾语与宾语补足语在逻辑上就相当于主语和表语的关系。 524 | 相比之下,间接宾语和直接宾语两者之间就没有这样的逻辑关系,所以加上be动词之后,自然是不能构成一个语义通顺的句子。 525 | 526 | 例句1: 527 | I made John our chairman. 528 | 【在宾语John后面加上is构成的句子是说得通的,即“John is our chairman”,因此是复合宾语】 529 | 参考译句:我选了约翰当我们的主席。 530 | 531 | 例句2: 532 | I made John a cake. 533 | 【在宾语John后面加上is构成的句子是说不通的,也就是“John is NOT a cake”,因此是双宾语】 534 | 参考译句:我给约翰做了一块蛋糕。 535 | 536 | ## “主谓宾宾补”结构的一种特殊用法 537 | 在feel, find, make, think, believe, consider等动词后,如果作宾语的是动词不定式(to do),且宾语补足语是形容词(间或是名词),常用it作形式宾语,而把动词不定式(to do)后移。 538 | 539 | 例句1: 540 | I find it difficult to work with him. 541 | 【形容词difficult作宾语补足语,形式宾语it代替真正的宾语,即不定式短语“to work with him”,放在宾语补足语的前面】 542 | 参考译句:我发现同他共事很难。 543 | 544 | 例句2: 545 | They considered it little use to spend more money on it. 546 | 【名词use作宾语补足语,形式宾语it代替真正的宾语,即不定式短语“to spend more money on it”,放在宾语补足语的前面】 547 | 参考译句:他们认为在那上面多花钱毫无用处。 548 | 549 | # 非谓语动词作宾语补足语1 550 | 在上次训练中,我们学习了“主谓宾宾补”这一句型结构,知道宾语补足语主要是由名词和形容词来充当的。 551 | 552 | 在接下来的两次训练中,我们再来学习一下非谓语动词作宾语补足语的相关用法。 553 | 554 | 非谓语动词三种形式之中的动词不定式(to do)和分词均可以在句中作宾语补足语,但是它们的具体使用情况却不尽相同。 555 | 556 | 本次训练,我们将围绕一些常见的动词进行展开,看一看到底哪些动词后面需要用动词不定式作宾语补足语,哪些动词后面又需要跟分词作宾语补足语,这其中有很多是需要记忆的内容。 557 | 558 | ## 常见的需要接动词不定式(to do)作宾语补足语的动词 559 | advise, allow, ask, cause, compel, drive, enable, encourage, expect, forbid, force, help, impel, inspire, instruct, invite, lead, motivate, permit, persuade, promise, prompt, push, recommend, request, require, stimulate, teach, tell, tempt, train, warn, urge等 560 | 561 | 例句: 562 | She asked me to answer the phone in her absence. 563 | 参考译句:她要我在她不在的时候接电话。 564 | 565 | ## 常见的需要接不带to的动词不定式作宾语补足语的动词 566 | 在一些动词之后,动词不定式(to do)作宾语补足语时不用to。这样的动词主要包括三类: 567 | 1)help(作宾语补足语的to可加可不加) 568 | 2)感觉、感官动词:feel, hear, listen to, see, watch, notice, observe, look at等 569 | 3)使役、致使动词:let, make, have等 570 | 571 | 例句1: 572 | Music can help you (to) relax after a day’s work. 573 | 参考译句:一天工作之余听听音乐能帮助你放松。 574 | 575 | 例句2: 576 | Someone saw her enter the house by the back door. 577 | 参考译句:有人看见她从后门进了那所房子。 578 | 579 | 例句3: 580 | The lawyer made her husband give up the property. 581 | 参考译句:那位律师使她的丈夫放弃了财产。 582 | 583 | ## 常见的需要接分词作宾语补足语的动词 584 | ### 分词的基本概念 585 | 分词是非谓语动词三种形式之一,分为现在分词和过去分词两种。现在分词的形式是“动词原形+-ing”,规则动词的过去分词形式是“动词原形+-ed”。 586 | 587 | 现在分词-ing与过去分词-ed的区别主要表现在语态和时间上。 588 | 在语态上,现在分词-ing表示主动意义,过去分词-ed表示被动意义;在时间上,现在分词-ing 589 | 表示动作正在进行,过去分词-ed表示动作的完成。 590 | 591 | 例1: 592 | a conquering army 所向披靡的军队【主动】 593 | A conquered city 被征服了的城市【被动】 594 | 595 | 例2: 596 | the rising sun 正在升起的太阳【正在进行】 597 | the risen sun 升起了的太阳【已经完成】 598 | 599 | ### 分词作宾语补足语 600 | 分词一般只在两类动词后作宾语补足语: 601 | 1)感觉、感官、意愿动词:feel, hear, see, watch, notice, find等 602 | 2)使役、致使动词:make, have, get, keep, leave, catch等 603 | 604 | 在这种用法中,现在分词-ing表示正在进行的主动意义,过去分词-ed表示已经完成的被动意义。 605 | 606 | 例句1: 607 | I found my hometown greatly changed.【已经完成的被动意义】 608 | 参考译句:我发现我的家乡变化很大。 609 | 610 | 例句2: 611 | I found those students studying very hard.【正在进行的主动意义】 612 | 参考译句:我发现那些学生非常努力。 613 | 614 | 例句3: 615 | I have kept you waiting a long time.【正在进行的主动意义】 616 | 参考译句:我让你久等了。 617 | 618 | 例句4: 619 | She still couldn’t make herself understood.【已经完成的被动意义】 620 | 参考译句:她还不能表达自己的意思。 621 | 622 | # 非谓语动词作宾语补足语2 623 | 在上次训练中,我们学习了非谓语动词作宾语补足语的相关用法。 624 | 625 | 本次训练,我们将继续围绕该语法点进行展开,加深对其的理解。 626 | 627 | 在非谓语动词作宾语这一部分的训练中,我们曾经说过,“疑问词+to do”结构可以作某些动词的宾语。类似地,“疑问词+to do”结构也可以作某些动词的宾语补足语。 628 | 629 | 例句: 630 | The doctor told him when to take the medicine. 631 | 参考译句:医生告诉他在什么时候应该吃药。 632 | 633 | # 主系表结构 634 | 在之前的训练中,我们先后学习了四种简单句的基本句型。 635 | 636 | 本次训练,我们来学习简单句的基本句型中的最后一种,即“主系表”结构。 637 | 638 | ## 谓语动词的特点 639 | 在“主系表”结构中,谓语动词是系动词。 640 | 这种动词并不表示具体的动作,而只是起连接主语和后面成分的作用。这种动词后面所接的成分是用来说明主语的特点,表明主语的性质特征的,因此被称之为表语,也就是能表示主语特征的成分。 641 | 642 | 例句: 643 | The solution is feasible. 644 | 【通过系动词is来连接the solution和feasible,其中feasible用于补充说明the solution的特征】 645 | 参考译句:该方案可行。 646 | 647 | 英语中最常见的系动词是be动词。除此之外,还有其它一些系动词,可以将其分为以下三类: 648 | 1)表示主语保持某种状态:stay, keep, remain, continue等 649 | 2)表示主语具有某种性质、特征、处于某种状态:feel, look, seem, taste, sound, appear等 650 | 3)表示主语由一种状态逐渐转变为另外一种状态:go, get, fall, turn, come, grow, become等 651 | 652 | 例句1: 653 | The weather continued fine for several days. 654 | 参考译句:天气连续几天都很晴朗。 655 | 656 | 例句2: 657 | The plan does not sound reasonable. 658 | 参考译句:这个计划听起来不太合理。 659 | 660 | 例句3: 661 | Global warming is becoming a serious problem. 662 | 参考译句:全球变暖正成为一个严重问题。 663 | 664 | 由以上例句可以看出,在句中充当表语的通常是形容词和名词。需要特别注意的是,副词不能作表语。 665 | 666 | ## 简单句叠加成复杂难句 667 | 668 | 例句1: 669 | Vitamins are organic compounds. 670 | 【主语是vitamins;谓语是系动词are;名词短语organic compounds是表语】 671 | 参考译句:维生素是一种有机化合物。 672 | 673 | 例句2: 674 | Vitamins are organic compounds necessary in small amounts in the diet for the normal growth and maintenance of life of animals, including man. 675 | 【necessary和for之间添加了介词短语“in small amounts in the diet”,整个形容词短语“necessary ... for...”修饰其前面的名词compounds】 676 | 参考译句:维生素是一种有机化合物,尽管在饮食中的含量很少,但却是所有动物(包括人类)正常生长和生命延续所必不可少的。 677 | 678 | 比较上面两个例句不难发现,第二个句子要比第一个句子复杂得多,但是基本句型并没有改变,其核心依然是“vitamins are organic compounds”这一“主系表”结构。 679 | 680 | # 非谓语动词作表语 681 | 在上次训练中,我们学习了简单句五种基本句型中的最后一种,即“主系表”结构,对于形容词和名词等充当表语的词性有了一个基本的认识。 682 | 683 | 本次训练,我们将继续围绕“主系表”这一结构进行展开,学习非谓语动词作表语的相关用法。 684 | 685 | 动词不定式(to do)、动名词-ing和分词(现在分词-ing以及过去分词-ed)这三种非谓语动词的形式均可以在句中作表语,但是它们所表达的意义却各不相同。 686 | 687 | 动词不定式作表语 688 | 动词不定式作表语时,通常用于表示目的或说明主语的具体内容。 689 | 690 | 例句1: 691 | To live is to do something worthwhile.【目的】 692 | 参考译句:活着就是要做一些有价值的事情。 693 | 694 | 例句2: 695 | My goal is to be a scientist.【说明主语的具体内容】 696 | 参考译句:我的目标是当一名科学家。 697 | 698 | 699 | 动名词作表语 700 | 动名词作表语时,侧重于表示一个行为动作。 701 | 702 | 例句: 703 | The most important thing is giving the new generation a good training. 704 | 参考译句:最重要的是对下一代进行良好的教育。 705 | 706 | 分词作表语 707 | 分词作表语时保持了它的形容词特征,对主语加以描述。其中,现在分词往往表示主语所具有的特征,过去分词往往表示主语的状态或状况。 708 | 709 | 例句1: 710 | The music is much pleasing to the ear.【主语所具有的特征】 711 | 参考译句:音乐优美悦耳。 712 | 713 | 例句2: 714 | They are satisfied with their present job.【主语的状态或状况】 715 | 参考译句:他们对现在的工作很满意。 716 | 717 | # 一般时态 718 | 在前面两个阶段的训练中,我们系统地学习了简单句的五种基本句型,这些句型的一个核心成分就是谓语动词。因此在这一阶段的训练中,我们将围绕和谓语动词有关的语法点进行展开,主要涉及动词的时态、语态以及主谓一致。 719 | 720 | 与汉语不同的是,英语动词要明确表明时态。虽然有多达16种时态,但是常用的只有几种,只要将它们掌握就可以了。 721 | 722 | 本次训练,我们首先来学习一下三种一般时态(一般现在时、一般过去时和一般将来时)的相关用法。 723 | 724 | ## 一般现在时 725 | ### 构成 726 | 用动词原形,第三人称单数有变化 727 | 基本变化规则是: 728 | 1)一般情况加“-s”(比如:laugh → laughs) 729 | 2)以辅音加“y”结尾的词把“y”改为“i”,再加“-es”(比如:study → studies);以元音加“y”结尾的词则直接加“-s”(比如:play → plays) 730 | 3)以“o、s、x、ch、sh”结尾的词加“-es”(比如:pass → passes) 731 | 4)动词be的变化形式是is、am、are 732 | 5)动词have的变化形式是have、has 733 | 734 | ### 功能 735 | 1)表示习惯的、永久性的或反复发生的动作 736 | 2)表示特征、能力或现时的情况或状态 737 | 3)表示普遍真理、事实,也用在格言中 738 | 739 | 例句1: 740 | I do some exercise every day.【习惯的动作】 741 | 参考译句:我每天做一些锻炼。 742 | 743 | 例句2: 744 | She lives in a villa at the foot of the hill.【现时的情况或状态】 745 | 参考译句:她住在山脚下的一栋别墅里。 746 | 747 | 例句3: 748 | The earth moves round the sun.【普遍真理】 749 | 参考译句:地球绕太阳转。 750 | 751 | ### 常见时间状语标志 752 | often、sometimes、usually、always、normally、generally、rarely、seldom、now and then、every day / week / month / year、on a daily / weekly / monthly / yearly basis等 753 | 754 | ## 一般过去时 755 | ### 构成 756 | 动词的过去式 757 | 规则动词的过去式变化形式是: 758 | 1)一般情况加“-d”或“-ed”(比如:laugh → laughed;live → lived) 759 | 2)以辅音加“y”结尾的词把“y”改为“i”,再加“-ed”(比如:study → studied);以元音加“y”结尾的词则直接加“-ed”(比如:play → played) 760 | 3)以一个元音加一个辅音结尾并且重读的词,双写词尾的辅音字母,再加“-ed”(比如:plan → planned) 761 | 4)动词be的变化形式是was、were 762 | 5)动词have的变化形式是had 763 | 764 | ### 功能 765 | 1)表示过去某个特定时间或某一段时间发生的动作或情况 766 | 2)表示过去的习惯动作 767 | 768 | 例句1: 769 | The foreign guests visited Shanghai last spring.【过去某个特定时间发生的动作】 770 | 参考译句:这些外国客人去年春天访问过上海。 771 | 772 | 例句2: 773 | When she was in the city, she often went to the Central Supermarket.【过去的习惯动作】 774 | 参考译句:她在这座城市期间,常去中央商场。 775 | 776 | ### 常见时间状语标志 777 | yesterday、just now、at that time、in those days、last night /week / month / year、时间词+ago(比如:three days ago)、in / on+过去的时间词(比如:in 2010)等。 778 | 779 | ## 一般将来时 780 | ### 构成 781 | will+动词原形 782 | 783 | ### 功能 784 | 1)表示将要发生的动作或存在的状态 785 | 2)表示将来反复发生的动作,也表示倾向、习惯、必然发生的事 786 | 787 | 例句1: 788 | I’ll take you there tomorrow.【将要发生的动作】 789 | 参考译句:我明天带你去那儿。 790 | 791 | 例句2: 792 | Oil and water will not mix together.【倾向】 793 | 参考译句:油和水不会混合在一起。 794 | 795 | ### 常见时间状语标志 796 | tomorrow、(very) soon、in (the) future、this week / month / year、next day / week / month / year、in+时间状语(比如:in a few minutes)等。 797 | 798 | ### 其它结构及其用法 799 | 1)be going to+动词原形:这种结构表示决定、打算要做什么事,或有迹象表明即将发生、可能会出现什么情况,有趋势,注定会 800 | 801 | 例句1: 802 | I am going to buy a new coat this winter.【决定、打算做……】 803 | 参考译句:今年冬天我打算买一件新大衣。 804 | 805 | 例句2: 806 | Look at the cloud! It’s going to rain.【有迹象表明即将发生……】 807 | 参考译句:瞧那乌云,天要下雨了。 808 | 809 | 2)be about+动词不定式:这种结构表示即将发生的动作,句中不可用表示未来时间的状语 810 | 811 | 例句: 812 | Sit down everyone. The film’s about to start. 813 | 参考译句:大家坐下,电影马上开始。 814 | 815 | # 进行时态 816 | 在上次训练中,我们一共学习了三种一般时态(一般现在时、一般过去时和一般将来时)的相关用法。 817 | 818 | 本次训练,我们来学习一下两种进行时态(现在进行时和过去进行时)的相关用法。 819 | 820 | ## 现在进行时 821 | ### 构成 822 | is / am / are+现在分词 823 | 基本变化规则是: 824 | 1)一般情况加“-ing”(比如:laugh → laughing;study → studying;play → playing) 825 | 2)以“e”结尾的词把“e”去掉,再加“-ing”(比如:live → living) 826 | 3)以一个元音加一个辅音结尾并且重读的词,双写词尾的辅音字母,再加“-ing”(比如:plan → planning) 827 | 4)动词be的变化形式是being 828 | 5)动词have的变化形式是having 829 | 830 | ### 功能 831 | 1)表示现在正在进行的动作或发生的事 832 | 2)表示现阶段正在进行的动作或发生的事 833 | 834 | 例句1: 835 | Now she is planning our schedule for the trip.【现在正在进行的动作】 836 | 参考译句:现在她正在为旅行制定时间表。 837 | 838 | 例句2: 839 | She is learning English Literature at college.【现阶段正在进行的动作】 840 | 参考译句:她目前在大学里学英国文学。 841 | 842 | ### 常见时间状语标志 843 | now、today、currently、at present、at this time、at this moment等 844 | 845 | ## 过去进行时 846 | ### 构成 847 | was / were+现在分词 848 | 849 | ### 功能 850 | 1)表示过去某一时刻正在进行的动作或发生的事 851 | 2)表示过去某一阶段一直在进行的动作或发生的事 852 | 853 | 例句1: 854 | He was playing table tennis at five yesterday afternoon.【过去某一时刻正在进行的动作】 855 | 参考译句:他昨天下午5点钟在打乒乓球。 856 | 857 | 例句2: 858 | We were talking about your book this morning.【过去某一阶段一直在进行的动作】 859 | 参考译句:我们今天上午一直谈论着你的书。 860 | 861 | ### 常见时间状语标志 862 | (just) then、at that time、this morning、yesterday afternoon、from 9 to 10 last night等 863 | 864 | ## 进行时态其它用法 865 | 动作动词的进行时与always、forever、continually、constantly等副词连用,带有某种感情色彩,这种动作可能使人感到不满、厌倦或觉得不合情理,也可能使人感到满意或表示赞赏。 866 | 867 | 例句1: 868 | The students are making progress constantly.【满意】 869 | 参考译句:学生们在不断进步。 870 | 871 | 例句2: 872 | She was always changing her mind.【不满】 873 | 参考译句:她老是改变主意。 874 | 875 | ## 进行时态用法注意事项 876 | 在英语中,有些动词一般不用于进行时态,主要包括以下几类: 877 | 1)表示感官的动词:see、hear、feel、taste、smell、notice、observe等 878 | 2)表示某种情感或精神状态的动词:believe、doubt、hate、imagine、know、(dis)like、love、prefer、realise、appreciate、recognise、remember、suppose、think、understand、want等 879 | 3)表示所属、类似、构成等关系的动词和系动词:be、belong、consist、contain、include、involve、lack、need、owe、own、possess等 880 | 881 | ## 进行时态与一般时态的用法比较 882 | 1)现在进行时表示暂时性动作;一般现在时表示经常性或永久性动作 883 | 2)过去进行时表示正在进行尚未完成的动作;一般过去时表示已经完成的动作 884 | 3)进行时态可以带有感情色彩;一般时态不带感情色彩,表示客观陈述 885 | 886 | 例句1: 887 | The computer is working perfectly.【暂时性】 888 | The computer works perfectly.【经常性】 889 | The city lies at the foot of the hill.【永久性】 890 | 891 | 例句2: 892 | She was writing a letter at nine last night.【正在进行尚未完成】 893 | She wrote a letter and posted it.【已经完成,因为信被寄走了】 894 | 895 | 例句3: 896 | His sister is always helping others.【赞扬】 897 | His sister helped the old man.【客观表述】 898 | 899 | # 完成(进行)时态 900 | 在上次训练中,我们学习了两种进行时态(现在进行时和过去进行时)的相关用法。 901 | 902 | 本次训练,我们来学习一下完成(进行)时态的相关用法, 主要涉及现在完成时、过去完成时和现在完成进行时。 903 | 904 | ## 现在完成时 905 | ### 构成 906 | have / has+过去分词 907 | 注:规则动词的过去分词变化形式与过去式相同,故不再赘述。 908 | 909 | ### 功能 910 | 1)表示过去所发生的动作或事情对现在的影响或产生的结果,着眼点在现在 911 | 2)表示一个从过去某个时间开始,延续到现在,并可能延续下去的动作 912 | 913 | 例句1: 914 | She has lost her wallet.【现在没钱花了】 915 | 参考译句:她的钱包丢了。 916 | 917 | 例句2: 918 | He has worked here for over twenty years. 919 | 参考译句:他在这里工作已有二十多年了。 920 | 921 | ### 常见时间状语标志 922 | 适用于功能1:yet、just、once、lately、recently、already、ever、never等 923 | 适用于功能2:since、so far、these days、for+时间段、during the last / past few years等 924 | 925 | ## 过去完成时 926 | ### 构成 927 | had+过去分词 928 | 注:规则动词的过去分词变化形式与过去式相同,故不再赘述。 929 | 930 | ### 功能 931 | 1)表示在过去某个动作或某个具体时间之前已经发生、完成的动作或情况 932 | 2)表示对后来动作的影响 933 | 934 | 例句1: 935 | By the end of last week she had written two papers. 936 | 参考译句:到上周末,她已经写了两篇论文。 937 | 938 | 例句2: 939 | He had eaten something before taking dinner.【吃饭时反倒没了胃口】 940 | 参考译句:他在饭前吃了些东西。 941 | 942 | ### 常见时间状语标志 943 | before, by the end of last term / week / month / year等 944 | 945 | ## 现在完成进行时 946 | ### 构成 947 | have / has been+现在分词 948 | 949 | ### 功能 950 | 1)表示一个从过去某时开始发生,一直延续到现在并可能延续下去的动作 951 | 2)表示重复(指断断续续,而非一直不停) 952 | 953 | 例句1: 954 | I have been cycling to work for the last two weeks. 955 | 参考译句:这两个星期以来我一直骑车上班。 956 | 957 | 例句2: 958 | We’ve been discussing the matter several times this year.【断断续续】 959 | 参考译句:我们今年已数次讨论过那件事。 960 | 961 | ### 常见时间状语标志 962 | since、for+时间段、during the last / past few years等 963 | 964 | ## 完成时态用法注意事项 965 | 在英语中,有些非延续性动词(动作一开始便结束的动词),在现在完成时中,不能同表示一段时间的状语连用。 966 | 常见的这类动词有:come、go、begin、start、become、arrive、leave、join、end、die、find、buy、finish、borrow、marry等。 967 | 968 | 错误的句子: 969 | Peter has got married for six years. 970 | 正确的句子: 971 | Peter got married six years ago. 972 | 参考译句:彼得六年前结的婚。 973 | Peter has been married for six years. 974 | 参考译句:彼得结婚六年了。 975 | 976 | # 被动语态 977 | 在之前的三次训练中,我们围绕英语动词的时态进行了详细地说明。 978 | 979 | 本次训练,我们将围绕英语动词的语态进行展开,主要涉及被动语态的构成、使用要点以及使用范围这三个方面的内容。 980 | 981 | 英语有两种语态:主动语态和被动语态。主动语态表示主语是谓语动作的执行者或施动者;被动语态表示主语是谓语动作的承受者或受动者。 982 | 983 | 例句1: 984 | They will widen the road.【主动】 985 | 参考译句:他们将拓宽道路。 986 | 987 | 例句2: 988 | The road will be widened.【被动】 989 | 参考译句:道路将被拓宽。 990 | 991 | ## 被动语态的构成 992 | be+过去分词 993 | 以动词ask为例,几种常见时态的被动语态形式如下: 994 | 一般现在时:am / is / are asked 995 | 一般过去时:was / were asked 996 | 一般将来时:will be asked 997 | 现在进行时:am / is / are being asked 998 | 过去进行时:was / were being asked 999 | 现在完成时:has / have been asked 1000 | 过去完成时:had been asked 1001 | 1002 | ## 被动语态的使用要点 1003 | 1)不及物动词不能用于被动语态(常见的这类动词有:occur、happen、lie、rise、emerge、appear、disappear等) 1004 | 2)有些不及物动词构成的短语动词不能用于被动语态(常见的这类短语动词有:take place、lead to、result in、contribute to、arise / result from、consist of、account for、belong to等) 1005 | 3)表示状态的动词不能用于被动语态(常见的这类动词有:lack、mean、hold、have、cost、contain、become、possess等) 1006 | 4)系动词不能用于被动语态(常见的这类动词有:seem、prove、remain、appear、look等) 1007 | 1008 | 例句1: 1009 | Many accidents occur in the home.【不及物动词】 1010 | 参考译句:许多事故都发生在家中。 1011 | 1012 | 例句2: 1013 | Great changes have taken place in my hometown.【不及物性的短语动词】 1014 | 参考译句:我的家乡发生了巨大变化。 1015 | 1016 | 例句3: 1017 | Sam lacks courage and intelligence.【表示状态的动词】 1018 | 参考译句:萨姆缺乏勇气和智慧。 1019 | 1020 | 例句4: 1021 | The government remained in control.【系动词】 1022 | 参考译句:政府继续控制着局势。 1023 | 1024 | ## 被动语态的使用范围 1025 | 1)不知道或不必指出动作的执行者 1026 | 2)强调动作的承受者 1027 | 1028 | 例句1: 1029 | The audience is asked to keep silence.【不必指出动作的执行者】 1030 | 参考译句:观众被要求保持安静。 1031 | 1032 | 例句2: 1033 | A new subway will be built in the city.【强调动作的承受者】 1034 | 参考译句:城里将建一条新地铁。 1035 | 1036 | # 主谓一致1 1037 | 在之前的四次训练中,我们围绕英语动词的时态和语态进行了详细地说明。 1038 | 1039 | 在接下来的两次训练中,我们将继续围绕动词这一句子的核心成分进行展开,主要讨论主谓一致的问题。 1040 | 1041 | 本次训练,我们首先来学习一下当主语的构成较为简单时,主谓一致需要遵循哪些规则。 1042 | 1043 | 当主语的构成较为简单时,主谓一致需要遵循的规则: 1044 | 1)动词不定式(短语)、动名词(短语)作主语时,谓语动词用单数形式 1045 | 2)不可数名词以及单数可数名词作主语时,谓语动词用单数形式 1046 | 3)复数可数名词作主语时,谓语动词用复数形式 1047 | 4)在“There be”句型中,谓语动词的数要和最靠近be的名词保持一致 1048 | 5)“the+形容词、分词等”作主语,泛指一类人时,谓语动词用复数形式 1049 | 1050 | 例句1: 1051 | To work hard is necessary.【动词不定式短语】 1052 | 参考译句:努力工作是需要的。 1053 | 1054 | 例句2: 1055 | Making speeches is not his strong point.【动名词短语】 1056 | 参考译句:演讲不是他的特长。 1057 | 1058 | 例句3: 1059 | More happiness means more beautiful things.【不可数名词】 1060 | 参考译句:多一份欢乐就多一份美好。 1061 | 1062 | 例句4: 1063 | The student is alert in answering the question.【单数可数名词】 1064 | 参考译句:这个学生回答问题小心谨慎。 1065 | 1066 | 例句5: 1067 | The students are encouraged to think creatively.【复数可数名词】 1068 | 参考译句:学生们被鼓励进行创造性思考。 1069 | 1070 | 例句6: 1071 | There is an orange and two apples on the table.【orange是单数名词】 1072 | 参考译句:桌子上有一只橘子和两个苹果。 1073 | 1074 | 例句7: 1075 | The wise are perceptive men.【“the wise”泛指“智者”】 1076 | 参考译句:聪明人是有洞察力的人。 1077 | 1078 | # 主谓一致2 1079 | 在上次训练中,我们学习了当主语的构成较为简单时,主谓一致需要遵循哪些规则。 1080 | 1081 | 本次训练,我们接着来学习一下当主语的构成较为复杂时,主谓一致又应当遵循哪些规则。 1082 | 1083 | 当主语的构成较为复杂时,主谓一致应当遵循的规则: 1084 | 1)主语含有修饰成分时,谓语动词的数要和中心词保持一致(比如:“the+名词+of...”这一结构作主语时,由于其中心词是of前面的名词,因此谓语动词的数要和该名词保持一致) 1085 | 2)单数名词作主语,后面紧跟as well as、in addition to、including、such as、rather than、(along / combined / coupled / together) with等结构时,谓语动词用单数形式 1086 | 1087 | 例句1: 1088 | The number of pages in this book is nine hundred.【中心词number是单数名词】 1089 | 参考译句:本书的页数是900。 1090 | 1091 | 例句2: 1092 | The teacher, as well as the students, likes this painting.【teacher是单数名词】 1093 | 参考译句:不仅学生,老师也喜欢这幅油画。 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | # FANBOYS 1100 | 通过前面三个阶段的训练,相信大家对于和简单句有关的语法点有了一定的掌握。 1101 | 1102 | 在这一阶段的训练中,我们将由简单句上升到并列句层面,围绕句子之间的连接进行展开。 1103 | 1104 | 本次训练,我们首先来学习7个常用于连接并列句的并列连词,它们分别是for、and、nor、but、or、yet、so。为了方便记忆,把这7个词的首字母连在一起,统称为“FANBOYS”。 1105 | 1106 | 含有两个或两个以上的独立分句的句子叫并列句,其中的独立分句处于平等的、互不依从的并列地位。英语并列句通常不能只用逗号隔开,而要用并列连词连接,连词前可用或不用逗号。 1107 | 1108 | 错误的句子: 1109 | Tom went to college, Jack joined the army.【逗号不能用来连接前后两个独立分句】 1110 | 正确的句子: 1111 | Tom went to college but Jack joined the army.【并列连词but连接前后两个独立分句】 1112 | 参考译句:汤姆上了大学,但杰克入伍了。 1113 | 1114 | ## for表示原因或理由(“因为”) 1115 | 1116 | 例句: 1117 | It must have rained, for the ground is wet. 1118 | 参考译句:准是下过雨了,因为地面是湿的。 1119 | 1120 | ## and表示平行、顺接、递进等 1121 | 1122 | 例句1: 1123 | Her brother is an engineer and her sister is a painter.【平行】 1124 | 参考译句:她哥哥是工程师,她妹妹是画家。 1125 | 1126 | 例句2: 1127 | He closed the window, turned off the light and left the room.【顺接:表示先后顺序】 1128 | 参考译句:他关上窗。熄了灯,离开了房间。 1129 | 1130 | 例句3: 1131 | She did the work and did it well.【递进】 1132 | 参考译句:她做了那项工作,而且做得很好。 1133 | 1134 | ## nor用于否定句后,引出另一否定句以补充前句(“也不”) 1135 | 1136 | 例句: 1137 | Cooking up a quick dish doesn’t mean you have to sacrifice flavour. Nor does fast food have to be junk food. 1138 | 参考译句:做一道快餐并不意味着你就得牺牲味道。快餐也不见得非得是垃圾食品。 1139 | 1140 | ## but和yet表示转折或对照(“但是;然而”) 1141 | 1142 | 例句1: 1143 | He is young, but he is experienced and responsible. 1144 | 参考译句:他很年轻,但是他既有经验,又认真负责。 1145 | 1146 | 例句2: 1147 | He is poor, yet he is clever and noble-hearted. 1148 | 参考译句:他很穷,然而人却很聪明,心地又善良。 1149 | 1150 | ## or表示选择(“或者;不然的话”) 1151 | 1152 | 例句1: 1153 | He left the key in the classroom or somewhere.【或者】 1154 | 参考译句:他把钥匙忘在了教室里或什么地方。 1155 | 1156 | 例句2: 1157 | Wear your coat or you’ll catch cold.【不然的话】 1158 | 参考译句:把大衣穿上,不然会感冒的。 1159 | 1160 | ## so表示结果(“所以”) 1161 | 1162 | 例句: 1163 | It is foggy today, so we can’t see the distant hills. 1164 | 参考译句:今天有雾,所以看不见远处的小山。 1165 | 1166 | ## 其它常见的并列连词:while和whereas表示对比(“而”) 1167 | 1168 | 例句: 1169 | Wise men seek after truth while / whereas fools despise knowledge. 1170 | 参考译句:智者求真理,愚人贬知识。 1171 | 1172 | ## 并列连词用法注意事项 1173 | 并列连词and可以和yet、so连用,但不能和but连用。换言之,“and yet”和“and so”是正确用法,而”and but“则是错误用法。 1174 | 1175 | 例句1: 1176 | This is strange and yet true. 1177 | 参考译句:这是奇怪的,但是真的。 1178 | 1179 | 例句2: 1180 | The meeting began at eight and so he must start at half past seven. 1181 | 参考译句:会议8点开始,所以他必须7点半动身。 1182 | 1183 | # 连接副词1 1184 | 在上次训练中,我们重点学习了“FANBOYS”的相关用法,了解了这些并列连词所表示的句子间的逻辑关系。 1185 | 1186 | 不过在实际考试的时候,无论是在听力文本还是阅读文章里,或是在写作、翻译的过程中,我们还会碰到或者需要用到其它一些用于体现句子之间逻辑关系的表达。因此,在接下来的三次训练中,我们都将围绕这些表达进行展开。 1187 | 1188 | 有些副词(短语)不是修饰句中的副词、形容词或动词,而是起承接作用,使上下文(句)意思连贯,语义衔接,形成具有逻辑性、连贯性的语篇。这类副词(短语)实际上起到类似于连词的作用,可以分为如下几类: 1189 | 1190 | 1)表示意义增补、补充和说明:besides、moreover、furthermore、additionally、in addition等 1191 | 1192 | 2)表示内容与上文类似或相同:similarly、likewise等 1193 | 1194 | 3)表示时间:meanwhile、at the same time等 1195 | 1196 | 4)表示结果:thus、therefore、consequently、as a result / consequence、for this reason等 1197 | 1198 | 5)表示意思相反(转折)、对比、让步:however、nevertheless、by contrast、on the one hand..., on the other hand...等 1199 | 1200 | 6)表示举例:for example / instance、to illustrate、a case in point等 1201 | 1202 | 7)表示观点的列举:firstly, secondly, finally、for one thing..., for another...等 1203 | 1204 | # 连接副词2 1205 | 本次训练,我们继续来学习用于体现句子之间逻辑关系的表达。 1206 | 1207 | 有些副词(短语)不是修饰句中的副词、形容词或动词,而是起承接作用,使上下文(句)意思连贯,语义衔接,形成具有逻辑性、连贯性的语篇。这类副词(短语)实际上起到类似于连词的作用,可以分为如下几类: 1208 | 1209 | 1)表示意义增补、补充和说明:besides、moreover、furthermore、additionally、in addition等 1210 | 1211 | 2)表示内容与上文类似或相同:similarly、likewise等 1212 | 1213 | 3)表示时间:meanwhile、at the same time等 1214 | 1215 | 4)表示结果:thus、therefore、consequently、as a result / consequence、for this reason等 1216 | 1217 | 5)表示意思相反(转折)、对比、让步:however、nevertheless、by contrast、on the one hand..., on the other hand...等 1218 | 1219 | 6)表示举例:for example / instance、to illustrate、a case in point等 1220 | 1221 | 7)表示观点的列举:firstly, secondly, finally、for one thing..., for another...等 1222 | 1223 | # 连接副词3 1224 | 本次训练,我们进一步巩固用于体现句子之间逻辑关系的表达。 1225 | 1226 | 有些副词(短语)不是修饰句中的副词、形容词或动词,而是起承接作用,使上下文(句)意思连贯,语义衔接,形成具有逻辑性、连贯性的语篇。这类副词(短语)实际上起到类似于连词的作用,可以分为如下几类: 1227 | 1228 | 1)表示意义增补、补充和说明:besides、moreover、furthermore、additionally、in addition等 1229 | 1230 | 2)表示内容与上文类似或相同:similarly、likewise等 1231 | 1232 | 3)表示时间:meanwhile、at the same time等 1233 | 1234 | 4)表示结果:thus、therefore、consequently、as a result / consequence、for this reason等 1235 | 1236 | 5)表示意思相反(转折)、对比、让步:however、nevertheless、by contrast、on the one hand..., on the other hand...等 1237 | 1238 | 6)表示举例:for example / instance、to illustrate、a case in point等 1239 | 1240 | 7)表示观点的列举:firstly, secondly, finally、for one thing..., for another...等 1241 | 1242 | # 句子的正确连接 1243 | 在之前的四次训练中,我们熟悉了并列连词“FANBOYS”以及各类可以起连词作用的副词(短语)所表示的句子之间的逻辑关系。 1244 | 1245 | 本次训练,也是这一阶段的最后一次训练,我们重点来学习一下如何将两个独立分句进行正确地连接,这一点在写作和翻译部分的测试中显得尤为重要。 1246 | 1247 | 两个独立分句之间的连接原则: 1248 | 1)逗号不具有连词的功能,因此不能直接用于连接前后两个独立分句。 1249 | 2)分号和句号的功能在语法上都类似于连词,可以用于连接前后两个独立分句。两者的主要区别在于──分号后面句子的首字母须小写;句号后面句子的首字母须大写。 1250 | 3)“FANBOYS”等并列连词可以直接用于连接前后两个独立分句。 1251 | 4)起连词作用的副词(短语)不能直接通过逗号来连接前后两个独立分句,需要配合分号、句号或并列连词使用。 1252 | 1253 | 错误的句子连接: 1254 | He studied hard, he passed the test.【逗号不具有连词的功能】 1255 | He studied hard; Therefore, he passed the test.【therefore位于分号后,首字母须小写】 1256 | He studied hard. therefore, he passed the test.【therefore位于句号后,首字母须大写】 1257 | He studied hard, therefore, he passed the test.【therefore是副词,不是连词】 1258 | 1259 | 正确的句子连接: 1260 | He studied hard; therefore, he passed the test.【分号可以用于连接前后两个独立分句】 1261 | He studied hard. Therefore, he passed the test.【句号可以用于连接前后两个独立分句】 1262 | He studied hard, so he passed the test.【so是并列连词,可以用于连接前后两个独立分句】 1263 | He studied hard, and therefore, he passed the test.【副词therefore搭配并列连词and使用】 1264 | 参考译句:他学习努力,所以通过了考试。 1265 | 1266 | # 识别名词性从句 1267 | 在上一个阶段的训练中,我们学习了如何通过一些衔接手段将简单句连成并列句。 1268 | 1269 | 在这一阶段的训练中,我们将由并列句上升到从句层面,围绕三大从句之一的名词性从句进行展开。 1270 | 1271 | 本次训练,我们先来认识一下主语从句、宾语从句、表语从句和同位语从句这四种名词性从句的类型,理解它们在句中充当的成分以及所处的位置。 1272 | 1273 | 一般来讲,名词在句中主要充当四种成分,分别是主语、宾语、表语和同位语。同样,我们可以把一个完整的句子当作名词来使用,在另外一个句子中充当这四种成分,于是便有了四种名词性从句。 1274 | 1275 | 例句1: 1276 | The book is interesting. 1277 | 【简单句:名词短语“the book”作主语】 1278 | 参考译句:这本书很有趣。 1279 | 1280 | What I am reading is interesting. 1281 | 【主语从句:完整的句子“what I am reading”作主语】 1282 | 参考译句:我在看的这本书很有趣。 1283 | 1284 | 例句2: 1285 | No one knows exactly the life on other planets. 1286 | 【简单句:名词短语“the life on other planets”作宾语】 1287 | 参考译句:没有人能够确切地知道外星人。 1288 | 1289 | No one knows exactly whether there is the life on other planets. 1290 | 【宾语从句:完整的句子“whether there is the life on other planets”作宾语】 1291 | 参考译句:没有人能够确切地知道是否有外星人存在。 1292 | 1293 | 例句3: 1294 | English is a useful tool. 1295 | 【简单句:名词短语“a useful tool”作表语】 1296 | 参考译句:英语是一门有用的工具。 1297 | 1298 | English is what I like most among all subjects. 1299 | 【表语从句:完整的句子“what I like most among all subjects”作表语】 1300 | 参考译句:英语是所有科目中我最喜欢的。 1301 | 1302 | 例句4: 1303 | I love the novel The Old Man and the Sea. 1304 | 【简单句:名词短语“The Old Man and the Sea”用于补充说明“novel”一词,作其同位语】 1305 | 参考译句:我喜欢《老人与海》这部小说。 1306 | 1307 | I love the saying that love, not time, heals all wounds. 1308 | 【同位语从句:完整的句子“that love, not time, heals all wounds”用于补充说明“saying”一词,作其同位语】 1309 | 参考译句:我喜欢这句话:是爱而不是时间能够治愈一切创伤。 1310 | 1311 | # 主语从句 1312 | 通过上次训练,相信大家对于四种名词性从句都有了一个初步的认识。从本质上讲,名词性从句就是用一个完整的句子来充当另外一个句子的四种句子成分,即主语、宾语、表语和同位语。 1313 | 1314 | 在接下来的四次训练中,我们就将依次学习这四种名词性从句。 1315 | 1316 | 本次训练,我们首先来学习一下引导名词性从句的连接词,围绕主语从句的相关用法进行展开。 1317 | 1318 | ## 引导名词性从句的连接词 1319 | 在英语中,一句话只能有一个谓语,因此在使用名词性从句时,必须要通过相应的连接词将其与句子的其它成分进行连接,否则就会出现“一句话有两个谓语”的情况,这是不符合语法要求的。 1320 | 1321 | 错误的句子: 1322 | He doesn’t understand English is obvious. 1323 | 【句中出现了“understand”和“is”两个谓语】 1324 | 正确的句子: 1325 | That he doesn’t understand English is obvious. 1326 | 【that起连接作主语的从句和后面主句的作用】 1327 | 参考译句:很显然,他不懂英语。 1328 | 1329 | 名词性从句的引导词一般可以分为以下三类: 1330 | 1)连词:that、whether和if 1331 | 2)连接代词:what, who, whom, whose, which 1332 | 3)连接副词:when, where, how, why 1333 | 1334 | 这些连接词的基本用法如下: 1335 | 1)that在名词性从句中既不充当任何成分,本身也没有任何实际意义,只起连接作用 1336 | 2)和that类似,whether和if在名词性从句中也不充当任何成分,但不同的是,其本身含有“是否”之意;考虑到if一般只在某些宾语从句中才可以使用,因此建议在表示“是否”的意思时用whether 1337 | 3)what在名词性从句中可以充当主语、宾语和表语,意为“什么” 1338 | 4)who在名词性从句中可以充当主语和表语,whom在名词性从句中充当宾语,两者均意为“谁” 1339 | 5)whose在名词性从句中充当定语,意为“谁的” 1340 | 6)which在名词性从句中可以充当主语和定语,“哪一个/哪一些” 1341 | 7)when、where、how和why在名词性从句中分别充当时间、地点、方式和原因状语,分别意为“何时/什么时候”、“何地、什么地方”、“如何/怎样”和“为什么” 1342 | 1343 | 关于这些连接词在从句中充当的成分及其本身所含的意思,我们会在下面讲解主语从句的用法时进行举例说明。 1344 | 1345 | ## 主语从句的相关用法 1346 | ### that引导的主语从句 1347 | that引导的主语从句较少被直接置于句首,更常见的情况是用it作形式主语,而将that引导的主语从句放在句末,构成“It+that从句”这一固定句型,具体有以下四类: 1348 | 1)It+be动词+形容词+that从句 1349 | 2)It+be动词+名词(短语)+that从句 1350 | 3)It+be动词+过去分词+that从句 1351 | 4)It+其它结构+that从句 1352 | 1353 | 例句1: 1354 | That I liked geography seemed strange to my father.【that被直接置于句首】 1355 | 参考译句:我喜欢地理,在我父亲看来,这很奇怪。 1356 | 1357 | 例句2: 1358 | It is true that English is becoming an international language.【It is+形容词+that从句】 1359 | 参考译句:的确,英语正日益成为一门国际通用语言。 1360 | 1361 | 例句3: 1362 | It is common knowledge that the whale is not a fish.【It is+名词短语+that从句】 1363 | 参考译句:鲸鱼不是鱼类,这是一个常识。 1364 | 1365 | 例句4: 1366 | It is estimated that a round-trip to Mars would take over a year.【It is+过去分词+that从句】 1367 | 参考译句:据估计,飞到火星来回的时间要超过一年。 1368 | 1369 | 例句5: 1370 | It seems that many of us have forgotten how to appreciate others.【It+不及物动词+that从句】 1371 | 参考译句:似乎许多人都已经忘记了如何感激别人。 1372 | 1373 | “It+that从句”是写作和翻译中的常用句型,需要大家重点掌握并能灵活运用。另外一点值得注意的是,虽然that在引导主语从句时只起连接作用,但是不能省略。 1374 | 1375 | ### 其它连接词引导的主语从句 1376 | 1377 | 例句1: 1378 | Whether or not these figures are accurate remains to be checked. 1379 | 【从句部分“these figures are accurate”不缺少任何成分,但缺少“是否”的含义,所以要用whether一词来引导;需要注意的是,此时的whether不能改成if,因为if不能用于引导主语从句】 1380 | 参考译句:这些数字是否确切还有待核对。 1381 | 1382 | 例句2: 1383 | What angered me most was his negative attitude. 1384 | 【从句部分“angered me most”缺少主语,表示“什么”,所以要用what一词来引导】 1385 | 参考译句:最使我生气的是他的消极态度。 1386 | 1387 | 例句3: 1388 | Who he is doesn’t concern me. 1389 | 【从句部分“he is”缺少表语,表示“谁”,所以要用who一词来引导】 1390 | 参考译句:他是谁与我无关。 1391 | 1392 | 例句4: 1393 | When the meeting is to be held has not yet been decided. 1394 | 【从句部分“the meeting is to be held”缺少时间状语,表示“何时”,所以要用when一词来引导】 1395 | 参考译句:会议什么时候举行还没决定。 1396 | 1397 | 例句5: 1398 | How a person masters his fate is very important. 1399 | 【从句部分“a person masters his fate”缺少方式状语,表示“怎样”,所以要用how一词来引导】 1400 | 参考译句:对于一个人来说,重要的是如何掌握自己的命运。 1401 | 1402 | 例句6: 1403 | Why he refused to cooperate with us is still a mystery. 1404 | 【从句部分“he refused to cooperate with us”缺少原因状语,表示“为什么”,所以要用why一词来引导】 1405 | 参考译句:他为什么会拒绝与我们合作,目前还不清楚。 1406 | 1407 | # 宾语从句 1408 | 在上次训练中,我们学习了引导名词性从句的三类连接词以及主语从句的相关用法。 1409 | 1410 | 本次训练,我们接着来学习另外一种常见的名词性从句,即宾语从句,顺便巩固一下三类连接词在从句中的使用条件,也就是在什么情况之下应该选择什么样的连接词。 1411 | 1412 | ## 动词的宾语从句 1413 | 1414 | 例句1: 1415 | We have reason to believe (that) she knew the victim quite well. 1416 | 【从句部分“she knew the victim quite well”不缺少任何成分,并且句意完整,所以要用that一词来引导;需要注意的是,此时的that通常可以省略】 1417 | 参考译句:我们有理由相信,她跟受害人很熟悉。 1418 | 1419 | 例句2: 1420 | I don’t know if / whether he needs my help. 1421 | 【从句部分“he needs my help”不缺少任何成分,但缺少“是否”的含义,所以要用if或whether一词来引导;需要注意的是,此时的whether可以改成if】 1422 | 参考译句:我不知道他是否需要我的帮助。 1423 | 1424 | 例句3: 1425 | I don’t know what she has bought for Father’s birthday. 1426 | 【从句部分“she has bought for Father’s birthday”缺少宾语,表示“什么”,所以要用what一词来引导,what在从句中充当动词bought的宾语】 1427 | 参考译句:我不知道她为父亲的生日买了什么。 1428 | 1429 | 例句4: 1430 | They couldn’t agree who should be sent there. 1431 | 【从句部分“should be sent there”缺少主语,表示“谁”,所以要用who一词来引导】 1432 | 参考译句:派谁去那儿,他们未能取得一致意见。 1433 | 1434 | 例句5: 1435 | He anticipated where the enemy would try to cross the river. 1436 | 【从句部分“the enemy would try to cross the river”缺少地点状语,表示“何地”,所以要用where一词来引导】 1437 | 参考译句:他预测敌人要在什么地方过河。 1438 | 1439 | ## 介词的宾语从句 1440 | 1441 | 例句1: 1442 | I haven’t settled the question of whether I’ll lend him the money. 1443 | 【从句部分“I’ll lend him the money”不缺少任何成分,但缺少“是否”的含义,所以要用whether 1444 | 一词来引导;需要注意的是,此时的whether不能改成if,因为if不能用于引导介词后的宾语从句】 1445 | 参考译句:我还没有决定是否把钱借给他。 1446 | 1447 | 例句2: 1448 | I have not decided whom I should vote for. 1449 | 【从句部分“I should vote for”缺少宾语,表示“谁”,所以要用whom一词来引导,whom在从句中充当介词for的宾语】 1450 | 参考译句:我还没有决定该投谁的票。 1451 | 1452 | 例句3: 1453 | Nobody could be sure of which kind of wildlife would be useful to us in future. 1454 | 【从句部分“kind of wildlife would be useful to us in future”缺少定语,表示“哪一种”,所以要用which一词来引导】 1455 | 参考译句:没有人有把握知道野生动植物中哪一种将来可能对我们有用。 1456 | 1457 | 例句4: 1458 | The police questioned him about where the car had been found. 1459 | 【从句部分“the car had been found”缺少地点状语,表示“什么地方”,所以要用where一词来引导】 1460 | 参考译句:警察盘问他这辆车是在哪里发现的。 1461 | 1462 | 需要特别注意的是,that不能用于引导介词后面的宾语从句。 1463 | 1464 | # 表语从句 1465 | 在上次训练中,我们学习了宾语从句的相关用法。 1466 | 1467 | 本次训练,我们继续来学习第三种名词性从句,即表语从句,进一步巩固三类连接词在从句中的使用条件,也就是在什么情况之下应该选择什么样的连接词。 1468 | 1469 | ## that引导的表语从句 1470 | 1471 | 例句: 1472 | My idea is that the child should be sent to school. 1473 | 【从句部分“the child should be sent to school”不缺少任何成分,且句意完整,所以要用that一词来引导;需要注意的是,此时的that通常不能省略】 1474 | 参考译句:我的看法是,应该把这个孩子送去上学。 1475 | 1476 | ## 其它连接词引导的表语从句 1477 | 1478 | 例句1: 1479 | My concern is whether he comes or not. 1480 | 【从句部分“he comes or not”不缺少任何成分,但是缺少“是否”的含义,所以要用whether一词来引导;需要注意的是,此时的whether不能改成if,因为if不能用于引导表语从句】 1481 | 参考译句:我关心的是他到底来不来。 1482 | 1483 | 例句2: 1484 | Money is what we are badly in need of. 1485 | 【从句部分“we are badly in need of”缺少宾语,表示“什么”,所以要用what一词来引导】 1486 | 参考译句:我们急需的是钱。 1487 | 1488 | 例句3: 1489 | Tomorrow is when it would be most convenient. 1490 | 【从句部分“it would be most convenient”缺少时间状语,表示“什么时候”,所以要用when一词来引导】 1491 | 参考译句:明天是最合适的时间。 1492 | 1493 | 例句4: 1494 | That’s where the river joins the sea. 1495 | 【从句部分“the river joins the sea”缺少地点状语,表示“什么地方”,所以要用where一词来引导】 1496 | 参考译句:那就是河流入海的地方。 1497 | 1498 | 例句5: 1499 | This is how Jane lives. 1500 | 【从句部分“Jane lives”缺少方式状语,表示“如何/怎样”,所以要用how一词来引导】 1501 | 参考译句:简就是这样生活的。 1502 | 1503 | 例句6: 1504 | That is why Jack got scolded. 1505 | 【从句部分“Jack got scolded”缺少原因状语,表示“为什么”,所以要用why一词来引导】 1506 | 参考译句:这就是杰克受训斥的原因。 1507 | 1508 | # 同位语从句 1509 | 在上次训练中,我们学习了表语从句的相关用法。 1510 | 1511 | 本次训练,我们再来学习一下最后一种名词性从句,即同位语从句。 1512 | 1513 | 所谓同位语,就是用来补充说明名词的成分。被补充说明的名词,叫作先行词;当用一个完整的句子来补充说明名词时,即构成同位语从句。所以,同位语从句通常都位于一个名词的后面,便构成了“名词+连接词+同位语从句”这样的结构。 1514 | 1515 | ## that引导的同位语从句 1516 | 1517 | 例句: 1518 | The news that we are invited to the conference is very encouraging. 1519 | 【从句部分“we are invited to the conference”不缺少任何成分,且句意完整,所以要用that一词来引导;需要注意的是,此时的that通常不能省略】 1520 | 参考译句:我们被邀请去参加会议的消息令人鼓舞。 1521 | 1522 | ## 其它连接词引导的同位语从句 1523 | 1524 | 例句1: 1525 | They are faced with the problem whether they should continue to work. 1526 | 【从句部分“they should continue to work”不缺少任何成分,但是缺少“是否”的含义,所以要用whether一词来引导;需要注意的是,此时的whether不能改成if,因为if不能用于引导同位语从句】 1527 | 参考译句:他们面临这样一个问题,即他们是否应该继续工作。 1528 | 1529 | 例句2: 1530 | The question who should go abroad on business tour requires consideration. 1531 | 【从句部分“should go abroad on business tour”缺少主语,表示“谁”,所以要用who一词来引导】 1532 | 参考译句:谁应该出差去国外,这个问题需要仔细考虑。 1533 | 1534 | 例句3: 1535 | I have no idea when he will return. 1536 | 【从句部分“he will return”缺少时间状语,表示“何时”,所以要用when一词来引导】 1537 | 参考译句:我不知道他什么时候回来。 1538 | 1539 | 例句4: 1540 | There arose the question where we could get the loan. 1541 | 【从句部分“we could get the loan”缺少地点状语,表示“什么地方”,所以要用where一词来引导】 1542 | 参考译句:现在的问题是我们去哪里弄到这笔贷款。 1543 | 1544 | # 非谓语动词作定语1 1545 | 在上一个阶段的训练中,我们学习了三大从句之一的名词性从句。 1546 | 1547 | 在这一阶段的训练中,我们将围绕“定语”这一修饰性的句子成分进行展开。 1548 | 1549 | 本次训练,我们首先来学习一下非谓语动词作定语的相关用法。 1550 | 1551 | 非谓语动词三种形式之中的动词不定式(to do)、动名词-ing和分词(现在分词-ing以及过去分词-ed)均可以在句中作定语,但是它们所表达的意义却各不相同。 1552 | 1553 | ## 动词不定式作定语 1554 | 动词不定式作定语时,需要放在被修饰名词的后面,构成后置定语。具体来说,动词不定式与其所修饰的名词之间有如下几种逻辑上的关系: 1555 | 1556 | 1)主谓关系 1557 | 所谓主谓关系,就是指被修饰的名词在逻辑意义上充当动词不定式中动词的主语。 1558 | 1559 | 例句: 1560 | The man to help you is Mr. Smith. 1561 | 【动词不定式“to help”的逻辑主语是“the man”,相当于“the man who can help you”】 1562 | 参考译句:愿意帮助你的人是史密斯先生。 1563 | 1564 | 2)动宾关系 1565 | 所谓动宾关系,就是指被修饰的名词在逻辑意义上充当动词不定式中动词的宾语。 1566 | 1567 | 例句1: 1568 | I have a paper to proofread. 1569 | 【动词不定式“to proofread”的逻辑宾语是“a paper”,相当于“proofread the paper”】 1570 | 参考译句:我有一篇文章要校对。 1571 | 1572 | 例句2: 1573 | He is a pleasant fellow to work with. 1574 | 【动词不定式“to work with”的逻辑宾语是“a pleasant fellow”,相当于“work with the pleasant fellow”】 1575 | 参考译句:他是个很好共事的人。 1576 | 1577 | 3)同位关系 1578 | 所谓同位关系,就是指动词不定式用来对被修饰的名词作进一步补充说明。 1579 | 1580 | 例句: 1581 | Your ability to analyse the problem really surprises us. 1582 | 【动词不定式“to analyse the problem”补充说明具体是哪一方面的“ability”】 1583 | 参考译句:你分析这个问题的能力真叫我们吃惊。 1584 | 1585 | 4)状语关系 1586 | 所谓状语关系,就是指被修饰的名词在逻辑意义上充当动词不定式中动词的状语。 1587 | 1588 | 例句1: 1589 | The time to go is July. 1590 | 【被修饰的名词“time”在逻辑意义上相当于动词不定式“to go”的时间状语,即“go at which time”】 1591 | 参考译句:应该在7月份去。 1592 | 1593 | 例句2: 1594 | A good place to eat is the restaurant around the corner. 1595 | 【被修饰的名词“place”在逻辑意义上相当于动词不定式“to eat”的地点状语,即“eat at which place”】 1596 | 参考译句:一个吃饭的好地方就是拐角的那家餐馆。 1597 | 1598 | 例句3: 1599 | Role playing is an enjoyable way to learn English. 1600 | 【被修饰的名词“way”在逻辑意义上相当于动词不定式“to learn English”的方式状语,即“learn English in which way”】 1601 | 参考译句:角色扮演是一个自得其乐的英语学习方式。 1602 | 1603 | ## 动名词作定语 1604 | 动名词作定语时,一般放在被修饰名词的前面,构成前置定语,通常用于表示所修饰名词的作用或用途。 1605 | 1606 | 例句: 1607 | No one is allowed to speak aloud in the reading room. 1608 | 【动名词“reading”说明被修饰名词“room”的用途】 1609 | 参考译句:阅览室里不准大声说话。 1610 | 1611 | ## 分词作定语 1612 | 1)单个分词作定语一般放在被修饰名词的前面,构成前置定语;分词短语作定语一般放在被修饰名词的后面,构成后置定语。 1613 | 2)现在分词作定语一般表示主动意义,强调动作正在进行;过去分词作定语一般表示被动意义,强调动作的完成。 1614 | 1615 | 例句1: 1616 | A barking dog seldom bites. 1617 | 【单个分词“barking”位于所修饰名词“dog”的前面,表示主动意义,强调动作正在进行,即“a dog is barking”】 1618 | 参考译句:吠犬不咬人。 1619 | 1620 | 例句2: 1621 | The suggestion sent to the committee was adopted. 1622 | 【分词短语“sent to the committee”位于所修饰名词“suggestion”的后面,表示被动意义,即“the suggestion was sent to the committee”】 1623 | 参考译句:呈送给委员会的建议被采纳了。 1624 | 1625 | # 非谓语动词作定语2 1626 | 本次训练,我们来进一步巩固非谓语动词作定语的相关用法。 1627 | 1628 | ## 动词不定式作定语 1629 | 动词不定式作定语时,需要放在被修饰名词的后面,构成后置定语。具体来说,动词不定式与其所修饰的名词之间有如下几种逻辑上的关系: 1630 | 1631 | 1)主谓关系 1632 | 所谓主谓关系,就是指被修饰的名词在逻辑意义上充当动词不定式中动词的主语。 1633 | 1634 | 例句: 1635 | The man to help you is Mr. Smith. 1636 | 【动词不定式“to help”的逻辑主语是“the man”,相当于“the man who can help you”】 1637 | 参考译句:愿意帮助你的人是史密斯先生。 1638 | 1639 | 2)动宾关系 1640 | 所谓动宾关系,就是指被修饰的名词在逻辑意义上充当动词不定式中动词的宾语。 1641 | 1642 | 例句1: 1643 | I have a paper to proofread. 1644 | 【动词不定式“to proofread”的逻辑宾语是“a paper”,相当于“proofread the paper”】 1645 | 参考译句:我有一篇文章要校对。 1646 | 1647 | 例句2: 1648 | He is a pleasant fellow to work with. 1649 | 【动词不定式“to work with”的逻辑宾语是“a pleasant fellow”,相当于“work with the pleasant fellow”】 1650 | 参考译句:他是个很好共事的人。 1651 | 1652 | 3)同位关系 1653 | 所谓同位关系,就是指动词不定式用来对被修饰的名词作进一步补充说明。 1654 | 1655 | 例句: 1656 | Your ability to analyse the problem really surprises us. 1657 | 【动词不定式“to analyse the problem”补充说明具体是哪一方面的“ability”】 1658 | 参考译句:你分析这个问题的能力真叫我们吃惊。 1659 | 1660 | 4)状语关系 1661 | 所谓状语关系,就是指被修饰的名词在逻辑意义上充当动词不定式中动词的状语。 1662 | 1663 | 例句1: 1664 | The time to go is July. 1665 | 【被修饰的名词“time”在逻辑意义上相当于动词不定式“to go”的时间状语,即“go at which time”】 1666 | 参考译句:应该在7月份去。 1667 | 1668 | 例句2: 1669 | A good place to eat is the restaurant around the corner. 1670 | 【被修饰的名词“place”在逻辑意义上相当于动词不定式“to eat”的地点状语,即“eat at which place”】 1671 | 参考译句:一个吃饭的好地方就是拐角的那家餐馆。 1672 | 1673 | 例句3: 1674 | Role playing is an enjoyable way to learn English. 1675 | 【被修饰的名词“way”在逻辑意义上相当于动词不定式“to learn English”的方式状语,即“learn English in which way”】 1676 | 参考译句:角色扮演是一个自得其乐的英语学习方式。 1677 | 1678 | ## 动名词作定语 1679 | 动名词作定语时,一般放在被修饰名词的前面,构成前置定语,通常用于表示所修饰名词的作用或用途。 1680 | 1681 | 例句: 1682 | No one is allowed to speak aloud in the reading room. 1683 | 【动名词“reading”说明被修饰名词“room”的用途】 1684 | 参考译句:阅览室里不准大声说话。 1685 | 1686 | ## 分词作定语 1687 | 1)单个分词作定语一般放在被修饰名词的前面,构成前置定语;分词短语作定语一般放在被修饰名词的后面,构成后置定语。 1688 | 2)现在分词作定语一般表示主动意义,强调动作正在进行;过去分词作定语一般表示被动意义,强调动作的完成。 1689 | 1690 | 例句1: 1691 | A barking dog seldom bites. 1692 | 【单个分词“barking”位于所修饰名词“dog”的前面,表示主动意义,强调动作正在进行,即“a dog is barking”】 1693 | 参考译句:吠犬不咬人。 1694 | 1695 | 例句2: 1696 | The suggestion sent to the committee was adopted. 1697 | 【分词短语“sent to the committee”位于所修饰名词“suggestion”的后面,表示被动意义,即“the suggestion was sent to the committee”】 1698 | 参考译句:呈送给委员会的建议被采纳了。 1699 | 1700 | # 关系代词1 1701 | 在之前的两次训练中,我们学习了非谓语动词作定语的相关用法。 1702 | 1703 | 在接下来的四次训练中,我们将围绕定语从句进行展开。 1704 | 1705 | 本次训练,我们先来认识一下什么是定语从句,并且学习一些常见的定语从句的引导词及其相关用法。 1706 | 1707 | 在英语中,我们通常用形容词作定语来修饰名词或名词短语,以表达一些相对简单的意思。 1708 | 1709 | 例句1: 1710 | I don’t like lazy people. 1711 | 参考译句:我不喜欢懒人。 1712 | 1713 | 但是,如果我们要表达稍微复杂一点的意思时,仅仅用形容词作定语对名词或名词短语进行修饰就很难做到了。此时,我们就得借助于一个句子来作定语,修饰某个名词或名词短语,这个句子即为定语从句。 1714 | 1715 | 例句2: 1716 | I don’t like people who never keep their word. 1717 | 参考译句:我不喜欢不守信用的人。 1718 | 1719 | ## 定语从句的基本概念 1720 | 对于定语从句,一定要掌握两个重要概念,即先行词和关系词。 1721 | 1722 | 被定语从句所修饰的对象称为先行词,上面例句2中的“people”一词即为先行词。 1723 | 1724 | 由于英语中一句话只能有一个谓语,因此在使用定语从句时,必须要通过相应的连接词将从句与主句连接起来,否则就会出现“一句话有两个谓语”的情况, 这里提到的连接词就是引导定语从句的关系词,上面例句2中的“who”一词即为关系词。 1725 | 1726 | 关系词主要有三个作用: 1727 | 1)重复指代先行词:上面例句2中的关系词“who”指代其前面的先行词“people” 1728 | 2)连接主句和定语从句:如果没有关系词“who”,上面例句2就会变成“I don’t like people never keep their word.”,其中出现了两个谓语,即“like”和“keep”,因此是错误的 1729 | 3)在定语从句中充当某种成分:上面例句2中的关系词“who”在定语从句中作主语 1730 | 1731 | ## 引导定语从句的关系代词 1732 | 定语从句的关系词一般可以分为以下两类: 1733 | 1)关系代词:that, which, who, whom, whose 1734 | 2)关系副词:when, where, why 1735 | 1736 | 本次训练,我们首先来了解一下关系代词的基本用法,具体如下: 1737 | 1)that引导定语从句,先行词既可以指“人”,也可以指“物”,在从句中可以充当主语和宾语 1738 | 2)which引导定语从句,先行词只能指“物”,在从句中可以充当主语和宾语 1739 | 3)who引导定语从句,先行词只能指“人”,在从句中充当主语 1740 | 4)whom引导定语从句,先行词只能指“人”,在从句中充当宾语 1741 | 5)whose引导定语从句,先行词既可以指“人”,也可以指“物”,在从句中充当定语 1742 | 1743 | 例句1: 1744 | They lived in a house that / which was built in 160## 1745 | 【先行词“house”指“物”,关系代词“that / which”在定语从句中作主语】 1746 | 参考译句:他们住在一栋1600年盖的房子里。 1747 | 1748 | 例句2: 1749 | This is an important factor that / which we must consider. 1750 | 【先行词“factor”指“物”,关系代词“that / which”在定语从句中作动词“consider”的宾语】 1751 | 参考译句:这是我们必须考虑的一个重要因素。 1752 | 1753 | 例句3: 1754 | The woman who / that lives next door is a famous dancer. 1755 | 【先行词“woman”指“人”,关系代词“who / that”在定语从句中作主语】 1756 | 参考译句:这位女士是一名著名的舞蹈演员,她就住在我家隔壁。 1757 | 1758 | 例句4: 1759 | The people whom / that you met yesterday are from England. 1760 | 【先行词“people”指“人”,关系代词“whom / that”在定语从句中作动词“met”的宾语】 1761 | 参考译句:你昨天碰到的那些人是从英国来的。 1762 | 1763 | 例句5: 1764 | I know a friend whose brother is a pop singer. 1765 | 【先行词“friend”指“人”,关系代词“whose”在定语从句中作定语,修饰“brother”一词】 1766 | 参考译句:我认识一个朋友,他哥哥是一名流行歌手。 1767 | 1768 | 例句6: 1769 | These children sit in a schoolroom whose windows are all broken. 1770 | 【先行词“schoolroom”指“物”,关系代词“whose”在定语从句中作定语,修饰“windows”一词】 1771 | 参考译句:这些孩子就坐在窗玻璃都打破了的教室里上课。 1772 | 1773 | # 关系代词2 1774 | 在上次训练中,我们了解了什么是定语从句,并且学习了引导定语从句的关系代词的相关用法。 1775 | 1776 | 本次训练,我们将继续围绕关系代词进行展开,重点来看两个方面的问题——一是定语从句中的主谓一致;二是关系代词的省略。 1777 | 1778 | ## 定语从句中的主谓一致 1779 | 定语从句中的谓语动词是用单数还是用复数,并不取决于关系代词,而是由先行词决定的。如果先行词在定语从句中作主语,那么从句的谓语动词在人称和数上应该与先行词保持一致。 1780 | 1781 | 例句: 1782 | We are studying sentences which contain adjective clauses. 1783 | 【先行词“sentences”是复数形式,并且在定语从句中作主语,所以从句谓语动词“contain”也要用复数形式,而不能用第三人称单数形式】 1784 | 参考译句:我们正在学习带有定语从句的句子。 1785 | 1786 | ## 关系代词的省略 1787 | 1)关系代词在定语从句中作宾语时,通常可以省略,但作主语时,则不能省略 1788 | 2)关系代词放在介词后作宾语时,不能省略,但介词位于句尾时,则可以省略 1789 | 1790 | 例句1: 1791 | The man (whom / that) you saw just now is our manager. 1792 | 【先行词“man”在定语从句中作动词“saw”的宾语,此时的关系代词“whom / that”可以省略】 1793 | 参考译句:你刚才见到的那个人是我们的经理。 1794 | 1795 | 例句2: 1796 | The man who saw you just now is our manager. 1797 | 【先行词“man”在定语从句中作主语,此时的关系代词“who”不能省略】 1798 | 参考译句:刚才见到你的那个人是我们的经理。 1799 | 1800 | 例句3: 1801 | This is the girl with whom he worked. 1802 | 【关系代词“whom”位于介词with之后,此时不能省略】 1803 | This is the girl (whom) he worked with. 1804 | 【介词with位于句尾,此时的关系代词“whom”可以省略】 1805 | 参考译句:这就是同他一起工作的女孩。 1806 | 1807 | 需要注意的是,如果关系代词紧跟在介词后面,不能用that或who,只能用which或whom。 1808 | 1809 | 例句: 1810 | This is the question about which they have had so much discussion in the past few weeks. 1811 | 【介词about后面的关系代词“which”不能用“that”替换】 1812 | 参考译句:这就是几周来他们反复讨论的那个问题。 1813 | 1814 | # 关系副词 1815 | 在之前的两次训练中,我们学习了引导定语从句的关系代词的相关用法。 1816 | 1817 | 本次训练,我们再来学习一下引导定语从句的关系副词的相关用法。 1818 | 1819 | ## 关系副词的基本用法 1820 | 引导定语从句的关系副词有三个,分别是when、where和why,其基本用法如下: 1821 | 1)when引导定语从句,先行词是表示时间的名词,在从句中充当时间状语 1822 | 2)where引导定语从句,先行词是表示地点的名词,在从句中充当地点状语 1823 | 3)why引导定语从句,先行词是表示原因的名词,在从句中充当原因状语 1824 | 1825 | 关系副词的意思相当于“介词+which”结构,具体来说: 1826 | 1)when = at, in, on, during which 1827 | 2)where = in, at which 1828 | 3)why = for which 1829 | 1830 | 例句1: 1831 | He will always remember the day when / on which his father returned from America. 1832 | 【先行词“day”表示时间,关系副词“when”在定语从句中作时间状语,相当于“his father returned from America on the day”,因此“when”可以用“on which”替换】 1833 | 参考译句:他将永远记着父亲从美国返回的那一天。 1834 | 1835 | 例句2: 1836 | The bookstore where / in which his sister works is the largest one in Nanjing. 1837 | 【先行词“bookstore”表示地点,关系副词“where”在定语从句中作地点状语,相当于“his sister works in the bookstore”,因此“where”可以用“in which”替换】 1838 | 参考译句:他妹妹工作的那家书店是南京最大的。 1839 | 1840 | 例句3: 1841 | I don’t know the reason why / for which he didn’t come to the meeting yesterday morning. 1842 | 【先行词是“reason”,关系副词“why”在定语从句中作原因状语,相当于“he didn’t come to the meeting yesterday morning for the reason”,因此“why”可以用“for which”替换】 1843 | 参考译句:我不知道他为什么没参加昨天上午的会议。 1844 | 1845 | ## 关系副词用法注意事项 1846 | 1)when引导定语从句,先行词是表示时间的名词;但先行词表示时间时,不一定都用when引导定语从句 1847 | 2)where引导定语从句,先行词是表示地点的名词;但先行词表示地点时,不一定都用where来引导定语从句 1848 | 3)why引导定语从句,先行词是表示原因的名词;但先行词表示原因时,不一定都用why来引导定语从句 1849 | 1850 | 例句1: 1851 | I’ll never forget the time which I spent on campus. 1852 | 【先行词“time”虽然表示时间,但是在定语从句中作动词“spent”的宾语,相当于“I spent the time on campus”,所以不能用关系副词“when”来引导】 1853 | 参考译句:我永远不会忘记在大学校园里度过的时光。 1854 | 1855 | 例句2: 1856 | I’ll never forget the day when we first met in the park. 1857 | 【先行词“day”表示时间,并且在定语从句中作时间状语,相当于“we first met in the park on the day”,所以要用关系副词“when”来引导】 1858 | 参考译句:我永远不会忘记我们第一次在公园见面时的情景。 1859 | 1860 | 例句3: 1861 | This is the town which I told you about before. 1862 | 【先行词“town”虽然表示地点,但是在定语从句中作介词about的宾语,相当于“I told you about the town”,所以不能用关系副词“where”来引导】 1863 | 参考译句:这就是我以前告诉过你的小城。 1864 | 1865 | 例句4: 1866 | This is the town where I spent my childhood. 1867 | 【先行词“town”表示地点,并且在定语从句中作地点状语,相当于“I spent my childhood in the town”,所以要用关系副词“where”来引导】 1868 | 参考译句:这就是我度过童年的小城。 1869 | 1870 | 例句5: 1871 | There are many contributing factors that cause global warming. 1872 | 【先行词“factors”虽然表示原因,但是在定语从句中作主语,相当于“factors cause global warming”,所以不能用关系副词“why”来引导】 1873 | 参考译句:导致全球变暖的因素有许多。 1874 | 1875 | 例句6: 1876 | This is the reason why I didn’t come here. 1877 | 【先行词“reason”表示原因,并且在定语从句中作原因状语,相当于“I didn’t come here for the reason”,所以要用关系副词“why”来引导】 1878 | 参考译句:这就是我没来的原因。 1879 | 1880 | ## how不能用来引导定语从句 1881 | 1882 | 错误的句子: 1883 | This is the way how he behaves. 1884 | 正确的句子: 1885 | This is the way (that / in which) he behaves. 1886 | 参考译句:这就是他的行为表现。 1887 | 1888 | 需要注意的是,当定语从句的先行词是“way”时,可以有三种方式来引导——一是用“that”;二是用“in which”(相当于“in the way”,即“以……的方式”);三是直接省略引导词。 1889 | 1890 | # 限制性VS非限制性 1891 | 在之前的三次训练中,我们先后学习了引导定语从句的关系代词以及关系副词的相关用法。这些定语从句的先行词与关系词之间都是没有逗号分隔的,但实际上还有一些定语从句,其先行词与关系词之间是有逗号分隔的。 1892 | 1893 | 本次训练,我们就将围绕定语从句的这一区别特征进行展开,学习两类不同的定语从句,也就是限制性定语从句和非限制性定语从句。 1894 | 1895 | ## 限制性定语从句的基本概念 1896 | 限制性定语从句用于提供必要的信息,对先行词起限定作用,去掉之后句意不完整,不能用逗号来分隔先行词和定语从句。 1897 | 1898 | 比如“I don’t like people.”这句话,意思就不是很明确,因此后面应当加上一个限制性定语从句,将句意补充完整。加上限制性定语从句之后可以这么说: 1899 | 1900 | I don’t like people who are never on time. 1901 | 【整个定语从句部分都是用来说明先行词“people”的性质的,是必不可少的信息,因此不能加上逗号将其变为非限制性定语从句】 1902 | 参考译句:我不喜欢不守时的人。 1903 | 1904 | ## 非限制性定语从句的基本概念 1905 | 非限制性定语从句用于提供附加的信息,对先行词作进一步解释或补充说明,去掉之后句意依然完整,不会引起误解和歧义,需要用逗号来分隔先行词和定语从句。 1906 | 1907 | 例句: 1908 | Beijing, which is the capital of China, has developed into an international city. 1909 | 【整个定语从句部分都是对先行词“Beijing”的补充说明,是附加而非必要的信息,因此可以加上逗号将其变为非限制性定语从句】 1910 | 参考译句:北京,中国的首都,已经成为了一个国际化都市。 1911 | 1912 | ## 非限制性定语从句的用法要点 1913 | 1)which可以引导非限制性定语从句,修饰前面的整个主句,代替主句所表示的整体概念或部分概念。在这种用法中,which在从句中一般作主语,并且从句的谓语动词要用第三人称单数形式。 1914 | 1915 | 例句: 1916 | In the presence of so many people he was little tense, which was understandable. 1917 | 【句中“which”引导的非限制性定语从句指代前面整个主句,而不是具体某个先行词】 1918 | 参考译句:在那么多人面前他有点紧张,这是可以理解的。 1919 | 1920 | 2)在非限制性定语从句中,关系代词as也可以代替整个主句,但相比于which来说,as所引导的从句位置较为灵活,可以位于主句前面、中间或后面,意为“如……一样”,而which代替整个主句时,一般只能位于主句后面 1921 | 1922 | 例句1: 1923 | As is reported, a foreign delegation will visit our factory. 1924 | 【关系代词“as”代替后面的句子,在定语从句中作主语】 1925 | 参考译句:正如报道所说,一个外国代表团将访问我们厂。 1926 | 1927 | 例句2: 1928 | The man was a scholar, as was evident from his way of walking. 1929 | 【关系代词“as”代替前面的句子,在定语从句中作主语,此时可以用“which”替换】 1930 | 参考译句:那人是一位学者,这从他的走路姿态明显看得出。 1931 | 1932 | ## 非限制性定语从句用法注意事项 1933 | 1)在非限制性定语从句中,一般不用that,而要用which或who 1934 | 2)关系副词why只能用于引导限制性定语从句,而关系副词when和where既可以引导限制性定语从句,也可以引导非限制性定语从句 1935 | 1936 | 例句1: 1937 | I met Professor Xu, who told me the result of the election. 1938 | 【此时的关系代词“who”不能用“that”替换】 1939 | 参考译句:我碰见徐教授,他告诉了我选举的结果。 1940 | 1941 | 例句2: 1942 | The Heavenly Lake, which is one of the world famous scenic spots, is on Tianshan Mountain. 1943 | 【此时的关系代词“which”不能用“that”替换】 1944 | 参考译句:天池是世界名胜之一,位于天山之上。 1945 | 1946 | 例句3: 1947 | He was left on an island, where he stayed for as long as three months. 1948 | 【此时的关系副词“where”引导的是一个非限制性定语从句】 1949 | 参考译句:他被抛到一个岛上,在那里待了三个月之久。 1950 | 1951 | # 非谓语动词作状语1 1952 | 在此之前的六次训练中,我们围绕“定语”这一修饰性的句子成分进行了详细地说明。 1953 | 1954 | 在接下来的六次训练中,我们将围绕另一种修饰性的句子成分“状语”进行展开。 1955 | 1956 | 本次训练,我们首先来学习一下非谓语动词作状语的相关用法。 1957 | 1958 | 非谓语动词三种形式之中的动词不定式(to do)和分词(现在分词-ing以及过去分词-ed)均可以在句中作状语。 1959 | 1960 | 具体来说,动词不定式作状语多用于表示目的,而分词作状语则可以用于表示时间、原因、方式或伴随情况、条件、结果、让步等。 1961 | 1962 | 动词不定式作状语──表示目的 1963 | 1)动词不定式作目的状语时,其动作发生在谓语动作之后,一般放在句子后部,也可以位于句首表示强调,有“to do”、“so as to do”、“in order to do”三种常见的形式,但是“so as to do”不能用于句首。 1964 | 1965 | 例句1: 1966 | He travelled around the world (so as / in order) to gather little-known facts about the disease.【动词不定式放在句子后部】 1967 | 参考译句:他走遍世界,收集鲜为人知的有关这种疾病的资料。 1968 | 1969 | 例句2: 1970 | To / In order to pass the exam, he worked hard at his lessons.【动词不定式位于句首表示强调,不用“So as to pass”】 1971 | 参考译句:为了能通过考试,他刻苦读书。 1972 | 1973 | 2)在英语中,目的一般用动词不定式表示,而不用“for doing”这一形式。 1974 | 1975 | 1976 | 例句: 1977 | We eat to live.【不用“for living”】 1978 | 参考译句:我们吃饭是为了活着。 1979 | 1980 | 分词作状语 1981 | 分词作状语时表示的动作是主语动作的一部分,与谓语所表示的动作或状态(几乎)同时发生,有时先于谓语动词的动作发生,一般要用逗号同其它句子成分隔开。 1982 | 1983 | 例句1: 1984 | Defeated, they withdrew into the valley.【分词动作先发生】 1985 | 参考译句:他们被打败了,退回到山谷中。 1986 | 1987 | 例句2: 1988 | He telephoned, saying that he wouldn’t come for supper.【分词动作同时发生】 1989 | 参考译句:他打电话说他不来吃晚饭了。 1990 | 1991 | 分词作状语──表示时间 1992 | 分词作时间状语时相当于when、while等引导的从句,这类状语通常放在句子前半部分。 1993 | 1994 | 例句1: 1995 | Hearing the news, they immediately set off for Shanghai. [= When they heard the news, they...] 1996 | 参考译句:听到这个消息,他们立即出发到上海去了。 1997 | 1998 | 例句2: 1999 | Seen from the tower, the south foot of the Purple Mountain is a sea of trees. [= When it is seen from the tower, the south foot of the Purple Mountain...] 2000 | 参考译句:从这个塔上远眺,紫金山南麓是树的海洋。 2001 | 2002 | 分词作状语──表示原因 2003 | 分词作原因状语时相当于as、since、because等引导的从句,这类状语多放在句子前半部分。 2004 | 2005 | 例句: 2006 | Being Sunday, the shops are overcrowded. [= As it was Sunday, the shops...] 2007 | 参考译句:因为是星期天,商店里顾客盈门。 2008 | 2009 | 分词作状语──表示方式或伴随情况 2010 | 分词作方式或伴随情况状语时不能用状语从句替换,但常可改写为并列成分。 2011 | 2012 | 例句1: 2013 | He walked down the hill, singing softly to himself. [= He walked down the hill and sang softly to himself.] 2014 | 参考译句:他从小山上走下来,一路哼着曲儿。 2015 | 2016 | 例句2: 2017 | He hurried to the hall, followed by two guards. [= He hurried to the hall and was followed by two guards.] 2018 | 参考译句:他快步走向大厅,身后跟着两个卫兵。 2019 | 2020 | 分词作状语──表示条件 2021 | 分词作条件状语时相当于if、unless等引导的从句,这类状语要放在句子前半部分。 2022 | 2023 | 例句1: 2024 | Turning to the right, you will find a path leading to his cottage. [= If you turn to the right, you...] 2025 | 参考译句:向右转弯,你就可以找到一条通到他的别墅的小路。 2026 | 2027 | 例句2: 2028 | Given another chance, I’ll do it much better. [= If I am given another chance, I...] 2029 | 参考译句:如果再给我一次机会,我会做得更好。 2030 | 2031 | 分词作状语──表示结果 2032 | 分词作结果状语时相当于so that等引导的从句,这类状语通常放在句子后半部分,分词前面往往有副词thus或thereby,并由逗号同前面的句子成分隔开,常可译为“于是;所以;因而”等。 2033 | 这种分词的逻辑主语既可以是句子的主语,也可以是前边的整个句子;逻辑主语若为前边的整个句子时,其作用相当于一个非限制性定语从句。 2034 | 2035 | 例句1: 2036 | The output of steel increased by 15% last year, reaching 3,000,000 tons.【分词的逻辑主语就是句子的主语“the output of steel”】 2037 | 参考译句:钢产量去年增长了15%,达到300万吨。 2038 | 2039 | 例句2: 2040 | Industrial robots have been brought into the workplace, (thus / thereby) leading to an increase 2041 | in productivity.【分词的逻辑主语是前边的整个句子,相当于“which has led to...”】 2042 | 参考译句:工业机器人已经被应用于工作场所中,因而提高了生产率。 2043 | 2044 | 分词作状语──表示让步 2045 | 分词作让步状语时相当于although、even if等引导的从句。 2046 | 2047 | 例句1: 2048 | Taking more care, I still made quite a few mistakes. [= Although I took more care, I still...] 2049 | 参考译句:尽管我多加小心,还是犯了不少错误。 2050 | 2051 | 例句2: 2052 | Wounded, the brave soldier continued to fight. [= Although he was wounded, the brave soldier...] 2053 | 参考译句:虽然受伤,那勇敢的战士仍然继续作战。 2054 | 2055 | 分词作状语时需注意事项 2056 | 1)分词作状语时,分词的逻辑主语必须和句子的主语保持一致。换句话说,句子的主语要么是 2057 | 分词表示的动作的执行者(即主动关系),此时应用现在分词-ing形式,要么是承受者(即被动关系),此时应用过去分词-ed形式。 2058 | 2059 | 错误的句子: 2060 | Waiting for a bus, a brick fell on my head.【分词的逻辑主语和句子的主语不一致──砖头既不能“等车”,也不能“被车等”】 2061 | 正确的句子: 2062 | When I was waiting for a bus, a brick fell on my head.【只有“人”才能“等车”】 2063 | 参考译句:等车的时候,一块砖头砸到我头上了。 2064 | 2065 | 2066 | 例句1: 2067 | Looking out of the window, I saw lots of people on the street.【主动关系,即“I look out of the window”】 2068 | 参考译句:望着窗外,我看见街上有许多人。 2069 | 2070 | 例句2: 2071 | Printed white, the house looks bigger.【被动关系,即“the house is printed white”】 2072 | 参考译句:漆成白色后,这房子像是大些了。 2073 | 2074 | 2)分词作状语时,有时前面可以用一个连词,相当于简化后的状语从句保留了连词。常用的连词有:when、while、after、before、if、unless、once、although等。 2075 | 2076 | 2077 | 例句1: 2078 | After taking the medicine, she felt better. (= After she took the medicine, she felt better.) 2079 | 参考译句:吃过药后,她感到好些了。 2080 | 2081 | 例句2: 2082 | Once deprived of oxygen, the brain dies. (= Once it is deprived of oxygen, the brain dies.) 2083 | 参考译句:一旦缺氧,大脑就会死亡。 2084 | 2085 | # 非谓语动词作状语2 2086 | 在上次训练中,我们学习了非谓语动词作状语的相关用法。考虑到这一部分内容的重要性,本次训练我们将进一步巩固该方面的知识。另外,在此基础之上,我们还会补充讲解分词作状语时的一种特殊情况,即分词的独立结构。 2087 | 2088 | 分词的独立结构通常包括两种形式──一是“名词+分词”作状语;二是“with+名词+分词”作状语。 2089 | 2090 | “名词+分词”作状语 2091 | 在绝大多数情况下,分词作状语时,分词的逻辑主语必须和句子的主语保持一致。 2092 | 如果分词的主语和句子的主语不一致,我们就要采用“名词+分词”这一结构作状语,这里的“名词”就是分词的逻辑主语,以区别于句子的主语。 2093 | 其中,“名词+现在分词”结构表示主动意义,“名词+过去分词”结构表示被动意义。 2094 | 2095 | 例句1: 2096 | Weather permitting, we’ll be going fishing tomorrow.【表示主动意义;permit的主语是weather,它和句子的主语we不一致,所以才有了自己的独立主语】 2097 | 参考译句:如果天气允许的话,我们明天就去钓鱼。 2098 | 2099 | 例句2: 2100 | All taken into consideration, his plan seems to be more workable.【表示被动意义;take into consideration的主语是all,它和句子的主语his plan不一致,所以才有了自己的独立主语】 2101 | 参考译句:从各方面考虑,他的计划似乎更可行。 2102 | 2103 | “with+名词+分词”作状语 2104 | “with+名词+分词”是在“名词+分词”这一结构作状语的基础上变化而来的,所表达的意义主要有两类──一是表示伴随情况、补充说明、具体举例等;二是表示原因。 2105 | 其中,“with+名词+现在分词”结构表示主动意义(正在进行或发生),“with+名词+过去分词”结构表示被动意义(已经完成)。 2106 | 2107 | 例句1: 2108 | She is now a beggar, with all her fortune gone.【伴随情况、补充说明;被动意义(已经完成)】 2109 | 参考译句:她现在成了乞丐,所有的财富都化为乌有了。 2110 | 2111 | 例句2: 2112 | With the temperature falling so rapidly, we couldn’t go on with the experiment.【原因;主动意义(正在发生)】 2113 | 参考译句:由于温度下降过快,我们不能继续进行实验了。 2114 | 2115 | # 时间、地点状语从句 2116 | 在之前的两次训练中,我们学习了非谓语动词作状语的相关用法。 2117 | 2118 | 在接下来的四次训练中,我们将着重讲解状语从句。 2119 | 2120 | 从本质上来说,状语从句就是用不同的连词将两个或两个以上的分句连接起来,以表达分句之间特定的逻辑关系。 2121 | 2122 | 状语从句有九大类,分别可以用来表示时间、地点、原因、方式、条件、让步、目的、结果以及比较。 2123 | 2124 | 在学习每一类状语从句时,我们都将围绕引导该类状语从句的常用连接词进行展开。 2125 | 2126 | 本次训练,我们首先来看一看时间和地点这两类状语从句。 2127 | 2128 | ## 时间状语从句 2129 | ### when、while和as 2130 | 1)when的意思相当于“at that time”,即“在……时刻”,从句谓语动词通常是短暂动词,表示某一时刻的动作,有时也可以是延续动词,表示某一时间段内发生的动作。 2131 | 2)while的意思相当于“during that time”,即“在……期间”,从句谓语动词通常是延续动词,表示某一时间段内发生的动作。 2132 | 3)as相当于while,从句谓语动词通常是延续动词,意为“正当……”;此外,as还可以用于表示“相随渐变”的情况,意为“随着……”或“一边……,一边……”。 2133 | 2134 | 例句1: 2135 | I was cooking supper when she arrived. 2136 | 【从句的谓语动词“arrived”是短暂动词】 2137 | 参考译句:她来到时我正在做晚饭。 2138 | 2139 | 例句2: 2140 | I learned French when I was very young. 2141 | 【从句的谓语动词“was”表示状态的延续】 2142 | 参考译句:我的法语是年轻时学的。 2143 | 2144 | 例句3: 2145 | The phone rang while I was watching TV. 2146 | 【从句的谓语动词“watching”是一个持续性动作】 2147 | 参考译句:当时我正在看电视,突然电话铃响了。 2148 | 2149 | 例句4: 2150 | As time passed, things seemed to get worse. 2151 | 【as表示“相随渐变”的情况,意为“随着……”】 2152 | 参考译句:随着时间的推移,情况似乎变得更糟。 2153 | 2154 | ### before和after 2155 | before和after表示的是两个时间或两个事件之间的先后关系。 2156 | 1)before引导的从句动作发生在主句动作之后,如果从句是过去时,主句一般要用过去完成时。 2157 | 2)after引导的从句动作发生在主句动作之前,如果主句是过去时,从句一般要用过去完成时。 2158 | 2159 | 例句1: 2160 | They had got everything ready before I arrived. 2161 | 参考译句:在我到达之前他们已经把一切都准备好了。 2162 | 2163 | 例句2: 2164 | After he had worked in the factory for ten years, he went abroad. 2165 | 参考译句:他在这家工厂工作了10年后就出国了。 2166 | 2167 | ### until 2168 | until的意思相当于“up to the time that”,即“直到……”或者“一直……为止”,表示一个动作持续到某一时刻或某一动作发生为止。 2169 | 在肯定句中,主句要用延续动词;在否定句中,“not... until”意为“直到……才”。 2170 | 2171 | 例句1: 2172 | She stood there until he had passed out of sight. 2173 | 【主句的谓语动词“stood”是一个持续性动作】 2174 | 参考译句:她站在那里看着,直到望不见他的身影。 2175 | 2176 | 例句2: 2177 | He didn’t have a girlfriend until he was thirty. 2178 | 参考译句:他直到30岁才有女朋友。 2179 | 2180 | ### since 2181 | since引导的从句多用短暂动词的一般过去时,主句一般要用现在完成时,意为“自……以来”。 2182 | 2183 | 例句: 2184 | Since he graduated from the college, he has worked in this city. 2185 | 参考译句:他大学毕业后一直在这个城市里工作。 2186 | 2187 | ### 其它连接词 2188 | 1)no sooner... than和hardly / scarcely... when:表示主句和从句的动作相继发生,意为“一……就”或“刚刚……就” 2189 | 2)as soon as, instantly, immediately, the moment等:表示从句的动作一发生,主句的动作随即发生,意为“一……就” 2190 | 2191 | 例句1: 2192 | He had hardly gone to bed when the door bell rang. 2193 | 参考译句:他刚刚睡下,门铃就响了。 2194 | 2195 | 例句2: 2196 | I shall come as soon as I’ve finished supper. 2197 | 参考译句:我一吃完晚饭就来。 2198 | 2199 | 例句3: 2200 | They told me the news immediately they got the message. 2201 | 参考译句:他们一得到口信就把消息告诉我了。 2202 | 2203 | ## 地点状语从句 2204 | 地点状语从句通常是由where引导,用于表示主句的动作发生的场所。 2205 | 2206 | 例句: 2207 | Air will be heavily polluted where there are factories. 2208 | 参考译句:在有工厂的地方空气污染都会很严重。 2209 | 2210 | ## 注意事项 2211 | 引导状语从句的都是连词,因此从句通常是一个完整的句子。 2212 | 2213 | 错误的句子: 2214 | His anger grew as he talking. 2215 | 【从句部分缺少谓语动词,“talking”是现在分词,不能充当谓语】 2216 | 2217 | 正确的句子: 2218 | His anger grew as he talked. 2219 | 【从句部分“he talked”是一个完整的句子,属于“主谓”结构】 2220 | 参考译句:他越说越生气。 2221 | 2222 | # 原因、方式状语从句 2223 | 在上次训练中,我们学习了时间和地点这两类状语从句。 2224 | 2225 | 本次训练,我们接着来学习原因和方式这两类状语从句。 2226 | 2227 | ## 原因状语从句 2228 | ### because、since和as 2229 | 1)because表示原因的语气最强 2230 | 2)since表示一种附带的原因,或者表示已知的、显然的理由,意为“既然” 2231 | 3)as表示的理由最弱,只是对主句的附带说明,重点在主句 2232 | 2233 | 例句1: 2234 | He was punished because he did not obey the rules. 2235 | 参考译句:他受了处分,因为他没有遵守规则。 2236 | 2237 | 例句2: 2238 | Since you say so, I suppose it is true. 2239 | 参考译句:你既然这么说,我想这是真的。 2240 | 2241 | 例句3: 2242 | As she was young, she was not equal to the task. 2243 | 参考译句:因为她还年轻,胜任不了这项工作。 2244 | 2245 | ### 介词短语表示因果关系 2246 | due to, owing to, because of, thanks to, in view of, as a result of等短语可以用于表示原因。 2247 | 2248 | 例句1: 2249 | Owing to lack of funds, the project will not continue next year. 2250 | 参考译句:由于缺乏资金,该项目明年将中止。 2251 | 2252 | 例句2: 2253 | As a result of the pilots’ strike, all flights have had to be cancelled. 2254 | 参考译句:由于飞行员罢工,所有航班都被迫取消了。 2255 | 2256 | 需要注意的是,因为这些短语具有介词性质,所以其后通常只能接名词(短语),而不是句子。 2257 | 2258 | 错误的句子: 2259 | We had an accident because of he was careless. 2260 | 【“he was careless”是一个完整的句子,而because of是介词短语,后面不能接句子】 2261 | 2262 | 正确的句子: 2263 | We had an accident because of his carelessness. 2264 | 【“his carelessness”是名词短语,不是句子,可以接在介词短语because of的后面】 2265 | 参考译句:因为他的疏忽大意,我们遭遇了车祸。 2266 | 2267 | ### 其它连接词 2268 | 1)in that:意为“原因就在于”,引导的从句要放在主句后面,而且主句通常是在作比较 2269 | 2)seeing (that), now (that), given (that), considering (that):意为“考虑到”或“鉴于某个事实” 2270 | 2271 | 例句1: 2272 | Mercury differs from other industrial metals in that it is a liquid. 2273 | 参考译句:水银不同于其它种类的工业用金属,原因就在于它是液态的。 2274 | 2275 | 例句2: 2276 | They did the job well, considering that they had no experience. 2277 | 参考译句:鉴于他们缺乏经验,这项工作他们就算做得不错了。 2278 | 2279 | ## 方式状语从句 2280 | ### as和just as 2281 | as和just as的意思相当于“in a particular way”或“in the same manner that...”,即“(正)如……”或“依照……”。just as比as更为强调。 2282 | 2283 | 例句1: 2284 | He paid her two thousand dollars as he had promised. 2285 | 参考译句:如他所答应过的,他付给了她2,000美元。 2286 | 2287 | 例句2: 2288 | The whole operation went exactly as it had been planned. 2289 | 参考译句:整个行动严格按照计划进行。 2290 | 2291 | 需要注意的是,引导方式状语从句的as是连词,因此从句通常是一个完整的句子,like虽然也有“像……一样”之意,但它是介词,所以其后通常只能接名词(短语),而不是句子。 2292 | 2293 | 错误的句子: 2294 | Please do it like I told you. 2295 | 【“I told you”是一个完整的句子,而like是介词,后面不能接句子】 2296 | 2297 | 正确的句子: 2298 | Please do it as I told you. 2299 | 【“I told you”是一个完整的句子,可以接在连词as的后面】 2300 | 参考译句:请按照我所讲的去做。 2301 | 2302 | ### as if和as though 2303 | as if和as though意为“好像;仿佛”,引导的从句用陈述语气时,表示所说的情况是事实或实现的可能性较大。 2304 | 2305 | 例句: 2306 | It looks as if / as though it is going to rain. 2307 | 参考译句:天看起来好像要下雨了。 2308 | 2309 | # 条件、让步状语从句 2310 | 在上次训练中,我们学习了原因和方式这两类状语从句。 2311 | 2312 | 本次训练,我们继续来学习条件和让步这两类状语从句。 2313 | 2314 | ## 条件状语从句 2315 | ### if和unless 2316 | 1)if表示正面的条件,意为“如果” 2317 | 2)unless表示反面的条件,意为“除非;如果不”,相当于“if... not” 2318 | 2319 | 例句1: 2320 | If we want light, we must conquer darkness. 2321 | 参考译句:我们要光明,就得征服黑暗。 2322 | 2323 | 例句2: 2324 | I shall go tomorrow unless it rains heavily. 2325 | 参考译句:除非明天下大雨,否则我就要走了。 2326 | 2327 | ### 其它连接词 2328 | as long as, suppose / supposing (that), provided / providing (that), on condition that等连词(词组)意思相近,有“如果;只要;假如,在……条件下”等意义 2329 | 2330 | 例句1: 2331 | As long as you keep on trying, you will surely succeed. 2332 | 参考译句:只要你继续努力,你就会成功。 2333 | 2334 | 例句2: 2335 | I will lend you the money on condition that you pay it back in one month. 2336 | 参考译句:我可以借钱给你,条件是你一个月内归还。 2337 | 2338 | ## 让步状语从句 2339 | ### though、although、even if和even though 2340 | 这几个连词(词组)都有“虽然;即使;尽管”的意思。其中,even if和even though带有强调的意味,语气较强,though和although语气较弱。 2341 | 2342 | 例句1: 2343 | I had a very good time although I didn’t know anybody at the party. 2344 | 参考译句:虽然在这次社交会上我谁也不认识,但我还是玩得很愉快。 2345 | 2346 | 例句2: 2347 | Even though you don’t like wine, just try a glass of this. 2348 | 参考译句:即使你不喜欢喝酒,也请尝一尝吧。 2349 | 2350 | ### despite和in spite of 2351 | 介词despite和介词短语in spite of也可以用于表示让步。 2352 | 2353 | 例句: 2354 | In spite of his inexperience, he did a very good job. 2355 | 参考译句:尽管他没有经验,但是他表现得很不错。 2356 | 2357 | 需要注意的是,因为despite和in spite of具有介词性质,所以其后通常只能接名词(短语),而不是句子。 2358 | 2359 | 错误的句子: 2360 | Despite he was inexperienced, he did a very good job. 2361 | 【“he was inexperienced”是一个完整的句子,而despite是介词,后面不能接句子】 2362 | 正确的句子: 2363 | Despite his being inexperienced, he did a very good job. 2364 | 【“his being inexperienced”是动名词短语,不是句子,可以接在介词despite的后面】 2365 | 参考译句:尽管他没有经验,但是他表现得很不错。 2366 | 2367 | ### while和whereas 2368 | while和whereas引导让步状语从句时,突出对比主句和从句所表示的两种差异的情况。 2369 | 2370 | 例句: 2371 | He is experienced while / whereas he is young. 2372 | 参考译句:他虽然年轻,但是很有经验。 2373 | 2374 | ### whatever、whenever、wherever、whoever、whichever和however 2375 | 这几个词引导让步状语从句时,相当于“no matter what / when / where / who / which / how”,其意思分别是“无论什么”、“无论何时”、“无论何处”、“无论谁”、“无论哪一个”、“无论如何”。 2376 | 2377 | 例句1: 2378 | Whatever / No matter what happens, we shall never lose confidence. 2379 | 参考译句:无论发生什么,我们都不会失去信心。 2380 | 2381 | 例句2: 2382 | Whoever / No matter who you are, you must obey the school regulations. 2383 | 参考译句:不管是谁,都必须遵守校规。 2384 | 2385 | 例句3: 2386 | Wherever / No matter where you go, I would keep you company. 2387 | 参考译句:不管你到哪里,我都会陪着你。 2388 | 2389 | ### 注意事项 2390 | 按照汉语习惯,在“虽然”引导的从句后面常用“但是”作为主句的开始,而英语却不允许在让步状语从句后用but。如果要强调前后两个部分的对比意义,可在主句前加yet。 2391 | 2392 | 错误的句子: 2393 | Although she has a lot of money, but she is unhappy. 2394 | 正确的句子: 2395 | Although she has a lot of money, (yet) she is unhappy. 2396 | 参考译句:她虽然有很多钱,但是却不幸福。 2397 | 2398 | # 目的、结果、比较状语从句 2399 | 在上次训练中,我们学习了条件和让步这两类状语从句。 2400 | 2401 | 本次训练,我们来再学习一下最后三类状语从句,分别是目的状语从句、结果状语从句以及比较状语从句。 2402 | 2403 | ## 目的状语从句 2404 | ### so that和in order that 2405 | 这两个连词短语意为“以便;为了”。 2406 | 2407 | 例句: 2408 | The teacher underlined the word so that / in order that the students might pay special attention to it. 2409 | 参考译句:教师在这个词下面画线,为的是让学生们特别注意该词。 2410 | 2411 | 对于目的状语从句,可以通过动词不定式(to do)来将其简化。 2412 | 2413 | 例句1: 2414 | We climbed high so that we might get a better view. 2415 | 例句2: 2416 | We climbed high (so as) to get a better view. 2417 | 参考译句:我们爬到高处,以便能看得更清楚。 2418 | 2419 | ### lest、in case和for fear that 2420 | 这三个连词(短语)意为“以防;以免”。 2421 | 2422 | 例句1: 2423 | He emphasised it again and again, lest she should forget. 2424 | 参考译句:他反复强调这一点,免得她忘了。 2425 | 2426 | 例句2: 2427 | They hid themselves behind some bushes in case / for fear that the enemy find them. 2428 | 参考译句:他们躲在树丛后面,以防被敌人发现。 2429 | 2430 | ## 结果状语从句 2431 | ### so that 2432 | 2433 | 例句: 2434 | He made a wrong decision, so that half of his lifetime was wasted. 2435 | 参考译句:他做了错误的决定,结果毁掉了半生。 2436 | 2437 | so that既可以引导目的状语从句,也可以引导结果状语从句,主要区别是: 2438 | 1)目的状语从句中的动词前要用may / might、can / could等情态动词,表示某种可能性、愿望,是主观意念。 2439 | 2)结果状语从句表示的是客观事实,较少使用情态动词,so that前常有逗号同主句隔开。 2440 | 2441 | 例句1: 2442 | She left early, so that she caught the train.【结果】 2443 | 参考译句:她动身早,所以赶上了火车。 2444 | 2445 | 例句2: 2446 | She left early so that she could catch the train.【目的】 2447 | 参考译句:她动身早,以便能赶上火车。 2448 | 2449 | ### so... that和such... that 2450 | 这两个连词短语意为“如此……以至于”,具体用法如下: 2451 | 1)so+形容词/副词/动词+that 2452 | 2)so+形容词+a / an+单数名词+that 2453 | 3)so+形容词+复数名词/不可数名词+that 2454 | 4)such+a / an+(形容词)+单数名词+that 2455 | 5)such+(形容词)+复数名词+that 2456 | 2457 | 例句1: 2458 | The wind was so strong that we could hardly move forward.【so+形容词+that】 2459 | 参考译句:风刮得那么大,我们简直寸步难行。 2460 | 2461 | 例句2: 2462 | It was so cold a day that all the pipes in the house froze up.【so+形容词+a+单数名词+that】 2463 | It was such a cold day that all the pipes in the house froze up.【such+a+形容词+单数名词+that】 2464 | 参考译句:天气极度寒冷,房子里所有的水管都冻结了。 2465 | 2466 | ## 比较状语从句 2467 | ### 连词as的基本用法 2468 | as引导比较状语从句,用于表示同等程度的比较,其基本结构是“as... as”或“the same... as”,在否定句中用“not so / as... as”或“not the same... as”。 2469 | 2470 | 例句1: 2471 | She dances as gracefully as her sister. 2472 | 参考译句:她的舞姿同她妹妹的一样优雅。 2473 | 2474 | 例句2: 2475 | The work is not as difficult as you think. 2476 | 参考译句:这项工作不像你想象的那么难。 2477 | 2478 | 例句3: 2479 | Your watch is not the same as mine. 2480 | 参考译句:你的表同我的表不一样。 2481 | 2482 | ### 连词than的基本用法 2483 | than引导比较状语从句,用于表示不同程度的比较,在使用时需要注意两个问题: 2484 | 1)可比性问题:两个同类事物才能比较,不是两个同类事物是无法比较的 2485 | 2)比较形式问题:在有than的比较句子里,主句中必须有比较级形式出现 2486 | 2487 | 错误的句子: 2488 | The weather of the South is wetter than the North. 2489 | 【the weather of the South和the North是两个截然不同的事物,无法进行比较】 2490 | 正确的句子: 2491 | The weather of the South is wetter than that of the North. 2492 | 【“南方的天气”和“北方的天气”是两个同类的事物,因此可以进行比较】 2493 | 参考译句:南方的天气比北方的天气更加潮湿。 2494 | 2495 | 错误的句子: 2496 | Ambitious students are much likely to succeed in their studies than are those with little ambition. 2497 | 【这个句子里有than,那么其前面就应该有比较级形式与其构成结构上的呼应】 2498 | 正确的句子: 2499 | Ambitious students are more likely to succeed in their studies than are those with little ambition. 2500 | 参考译句:有远大抱负的学生比起那些胸无大志的学生,更可能取得学业上的成功。 2501 | 2502 | ### 表示倍数比较的三种句型 2503 | 英语中,除了用than和as来对两个事物进行比较外,还可以用twice或times等词来说明两个事物之间的倍数关系,基本句型主要有以下三种(以three times,即三倍,为例): 2504 | 2505 | 1)“倍数+比较级”结构:A is three times bigger (或其它形态词的比较级) than B. 2506 | 2)“倍数+as… as”结构:A is three times as big (或其它形态词的原级) as B. 2507 | 3)“倍数+名词”结构:A is three times the size (或其它形态词对应的名词形式) of B. 2508 | 2509 | ### “the more..., the more”句型 2510 | 该句型的基本意思是“越……,越……”。 2511 | 2512 | 例句: 2513 | The more exactly you use your words, the more easily people will understand you. 2514 | 参考译句:你用词越准确,人们就能越容易理解你的意思。 2515 | 2516 | -------------------------------------------------------------------------------- /Shanbay/login.py: -------------------------------------------------------------------------------- 1 | import requests, json 2 | 3 | 4 | def login(username, password): 5 | user_agent = 'bayAgent/1.1 Android/5.1.1 com.shanbay.words/7.9.120 tencent-channel/0 HUAWEI/HUAWEI_M2-A01W ' \ 6 | 'frontend/1.8 api/2.3 ' 7 | session = requests.Session() 8 | session.headers['User-Agent'] = user_agent 9 | login_url = 'https://rest.shanbay.com/api/v1/account/login' 10 | data = { 11 | 'username': username, 12 | 'password': password, 13 | 'token': None 14 | } 15 | session.put(login_url, data=data) 16 | r = json.loads(session.put(login_url, data=data).text) 17 | return session if r['msg'] == 'SUCCESS' else None 18 | 19 | -------------------------------------------------------------------------------- /util/downloader.py: -------------------------------------------------------------------------------- 1 | from util.throttle import Throttle 2 | import requests 3 | 4 | 5 | class Downloader: 6 | def __init__(self, delay=3, cache={}): 7 | self.throttle = Throttle(delay) 8 | self.user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) " 9 | "Chrome/61.0.3163.100 Safari/537.36" 10 | # self.proxies = dict(http='socks5://127.0.0.1:1086', 11 | # https='socks5://127.0.0.1:1086') 12 | self.proxies = None 13 | self.cache = cache 14 | self.num_retries = None 15 | 16 | def __call__(self, url, num_retries=2): 17 | self.num_retries = num_retries 18 | try: 19 | result = self.cache[url] 20 | print('Load from cache: ' + url) 21 | except KeyError: 22 | result = None 23 | if result and num_retries and 500 <= result['code'] < 600: 24 | result = None 25 | 26 | if result is None: 27 | self.throttle.wait(url) 28 | result = self.download(url) 29 | self.cache[url] = result 30 | 31 | return result['html'] 32 | 33 | def download(self, url): 34 | print('Downloading: ' + url) 35 | try: 36 | resp = requests.get(url, headers={ 37 | 'User-Agent': self.user_agent 38 | }, proxies=self.proxies) 39 | # resp.encoding = 'utf8' 40 | html = resp.text 41 | if resp.status_code >= 400: 42 | print('Download error: ' + html) 43 | # 重下 44 | if 500 <= resp.status_code < 600 and self.num_retries: 45 | self.num_retries -= self.num_retries 46 | return self.download(url) 47 | except requests.exceptions.RequestException as e: 48 | html = None 49 | print('Download error: ' + e) 50 | 51 | return {'html': html, 'code': resp.status_code} 52 | -------------------------------------------------------------------------------- /util/redisCache.py: -------------------------------------------------------------------------------- 1 | from redis import StrictRedis 2 | import json, zlib 3 | 4 | 5 | class RedisCache: 6 | def __init__(self, client=None, compress=True, encoding='utf8'): 7 | self.client = StrictRedis(host='localhost', port=6379, db=0) \ 8 | if not client else client 9 | self.encoding = encoding 10 | self.compress = compress 11 | 12 | def __getitem__(self, url): 13 | record = self.client.get(url) 14 | if record and self.compress: 15 | record = zlib.decompress(self.client.get(url)) 16 | 17 | if record is None: 18 | raise KeyError(url + 'dose not exist') 19 | else: 20 | return json.loads(record.decode(self.encoding)) 21 | 22 | def __setitem__(self, url, result): 23 | self.client.set(url, zlib.compress(json.dumps(result).encode(self.encoding))) 24 | 25 | -------------------------------------------------------------------------------- /util/redisQueue.py: -------------------------------------------------------------------------------- 1 | import redis 2 | from redis import StrictRedis 3 | 4 | 5 | class RedisQueue: 6 | def __init__(self, client=None, name='crawler'): 7 | assert isinstance(client, (redis.client.StrictRedis, type(None))) 8 | self.client = StrictRedis(host='localhost', port=6379, db=0) \ 9 | if client is None else client 10 | self.queue = 'queue:%s' % name 11 | self.seen_set = 'set:%s' % name 12 | self.depth = 'depth:%s' % name 13 | 14 | def __len__(self): 15 | return self.client.llen(self.queue) 16 | 17 | def __repr__(self): 18 | return str(self.client.lrange(self.queue, 0, -1)) 19 | 20 | def already_seen(self, element): 21 | return self.client.sismember(self.seen_set, element) 22 | 23 | def push(self, element): 24 | if isinstance(element, list): 25 | element = list(filter(lambda e: not self.already_seen(e), element)) 26 | if element: 27 | self.client.lpush(self.queue, *element) 28 | self.client.sadd(self.seen_set, *element) 29 | elif not self.already_seen(element): 30 | self.client.lpush(self.queue, element) 31 | self.client.sadd(self.seen_set, element) 32 | 33 | def pop(self): 34 | return self.client.rpop(self.queue).decode('utf-8') 35 | 36 | def clear(self): 37 | self.client.delete(self.queue, self.seen_set, self.depth) 38 | 39 | def set_depth(self, element, depth): 40 | return self.client.hset(self.depth, element, depth) 41 | 42 | def get_depth(self, element): 43 | return int(self.client.hget(self.depth, element) or 0) 44 | -------------------------------------------------------------------------------- /util/throttle.py: -------------------------------------------------------------------------------- 1 | from urllib.parse import urlparse 2 | import time 3 | 4 | 5 | class Throttle: 6 | def __init__(self, delay): 7 | self.delay = delay 8 | self.domains = {} 9 | 10 | def wait(self, url): 11 | domain = urlparse(url).netloc 12 | last_accessed = self.domains.get(domain) 13 | if self.delay > 0 and last_accessed is not None: 14 | remain = self.delay - (time.time() - last_accessed) 15 | if remain > 0: 16 | time.sleep(remain) 17 | self.domains[domain] = time.time() 18 | --------------------------------------------------------------------------------