Skip to content

Commit

Permalink
更新demo和改名
Browse files Browse the repository at this point in the history
  • Loading branch information
princehaku committed Sep 11, 2013
1 parent d22dcc9 commit 00db850
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
20 changes: 13 additions & 7 deletions demo/basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ action: main
name: "vc cartoon"
subaction:
- action: fetcher
url: http://www.verycd.com/base/cartoon/page${0,1}${0,9}
url: http://www.verycd.com/base/cartoon/page${0,1}${0,1}
subaction:
- action: parser
rule: .entry_cover_list li
Expand All @@ -11,10 +11,16 @@ subaction:
group: default
subaction:
- {action: parser, rule: '.entry_cover .cover_img', setField: img}
- {action: parser, rule: 'a', pos: 0, attr: href, setField: src}
- {action: parser, strip: 'true', rule: '.entry_cover .score', setField: score}
- {action: parser, rule: '.bio a', setField: dest}
- action: fetcher
url: http://www.verycd.com${#src}
-
action: parser
rule: 'a'
pos: 0
attr: href
setField: src
subaction:
- {action: parser,strip: 'true', rule: '#contents_more', setField: description}
- action: fetcher
url: http://www.verycd.com${#src}
subaction:
- {action: parser,strip: 'true', rule: '#contents_more', setField: description}
- {action: parser, strip: 'true', rule: '.entry_cover .score', setField: score}
- {action: parser, rule: '.bio a', setField: dest}
6 changes: 3 additions & 3 deletions pyrailgun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def __main(self, task_entry):
def __fetch_webkit(self, task_entry):
p = Pattern(task_entry, self.__getCurrentShell(task_entry), self.global_data)

import cwebbrowser
import _cwebbrowser

task_entry['datas'] = []

Expand All @@ -117,7 +117,7 @@ def __fetch_webkit(self, task_entry):
if not url:
# do not fetch null url
continue
browser = cwebbrowser.CWebBrowser(delay=delay)
browser = _cwebbrowser.CWebBrowser(delay=delay)
#browser.show();
if task_entry.get('cookie'):

Expand All @@ -136,7 +136,7 @@ def __fetch_webkit(self, task_entry):
# block
try:
browser.load(url=url, load_timeout=timeout, tries=1)
except cwebbrowser.SpynnerTimeout:
except _cwebbrowser.SpynnerTimeout:
self.logger.error("fetch " + url + " timeout ")
else:
html = browser.html
Expand Down
20 changes: 10 additions & 10 deletions pyrailgun/cwebbrowser.py → pyrailgun/_cwebbrowser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,26 @@
from StringIO import StringIO

HAS_PYSIDE = False
from PyQt4 import QtCore

from PyQt4.QtCore import SIGNAL, QUrl, QString, Qt, QEvent
from PyQt4.QtCore import QSize, QDateTime, QPoint
from PyQt4.QtGui import QApplication, QImage, QPainter
from PyQt4.QtGui import QCursor, QMouseEvent, QKeyEvent
from PyQt4.QtNetwork import QNetworkCookie, QNetworkAccessManager, QSslConfiguration, QSslCipher
from PyQt4.QtNetwork import QNetworkCookieJar, QNetworkRequest, QNetworkProxy, QSsl, QSslSocket
from PyQt4.QtGui import QCursor, QKeyEvent
from PyQt4.QtNetwork import QNetworkCookie, QNetworkAccessManager, QSslConfiguration
from PyQt4.QtNetwork import QNetworkCookieJar, QNetworkRequest, QNetworkProxy
from PyQt4.QtWebKit import QWebPage, QWebView
from PyQt4.QtWebKit import QWebInspector

SpynnerQapplication = None


import _cwebbrowser

# Debug levels
ERROR, WARNING, INFO, DEBUG = range(4)
argv = ['dummy']
_marker = []

import cwebbrowser


class CWebBrowser(object):
"""
Expand Down Expand Up @@ -120,9 +120,9 @@ def __init__(self,
):
ciphers.append(cip)
self.sslconf.setCiphers(ciphers)
if not cwebbrowser.SpynnerQapplication:
cwebbrowser.SpynnerQapplication = QApplication(cwebbrowser.argv)
self.application = cwebbrowser.SpynnerQapplication
if not _cwebbrowser.SpynnerQapplication:
_cwebbrowser.SpynnerQapplication = QApplication(_cwebbrowser.argv)
self.application = _cwebbrowser.SpynnerQapplication
self.want_compat = want_compat
self.debug_stream = debug_stream
self.user_agent = user_agent
Expand Down Expand Up @@ -1176,7 +1176,7 @@ def get_cookies(self):
return self.cookiesjar.mozillaCookies()

def add_cookie(self, domain, name, value):
self.logger.debug("set cookie " + domain + " " + name + " " + value)
self._debug(INFO, "set cookie " + domain + " " + name + " " + value)
return self.cookiesjar.add_cookie(domain, name, value)

def set_cookies(self, string_cookies):
Expand Down

0 comments on commit 00db850

Please sign in to comment.