跳至內容

使用者討論:Vipuser/2006-5

頁面內容不支援其他語言。
新增話題
維基詞典,自由的多語言詞典

歡迎![編輯]

向日葵
向日葵

Vipuser 您好!

歡迎您加入到維基詞典大家庭!這是一個創作自由的免費的人人可編輯的多語言詞典的協作計劃,它的目的是為了描述人類古今的所有詞語並用中文來解釋它們。這包括着每種語言的語源讀音解釋維基詞典中文版始於2004年5月,至今為止已有1,713,256個大大小小的詞條。請參見常見問題幫助來獲得有關如何使用本網站的更多信息。維基詞典中的所有內容均在GNU自由文檔協議證書下發布,這意味着它將是完全自由的。詳細信息請參見版權

如果您有興趣參與這項重大工程的編輯工作,您可以把自己的用戶名加入到維基詞典人列表上。如果您在編輯方面遇到了困難,歡迎您在啤酒館提出。如果您對某一單詞持有疑問,請在茶室里提出。您也可以直接在我的對話頁上留言,會儘快地給您回復。如果您對維基還比較陌生,可以參考如何編輯頁面體例說明繁簡轉換布局解釋或到社群首頁與別的維基人交往。與別的維基人交往時請在有關用戶的對話頁上留言(點擊左上角的"討論本頁"即可進入)。留言時請在言尾註上您的用戶名與留言時間(國際協調時),點擊編輯框左上角的或輸入--~~~~即可。別的維基人都是像您我一樣的真人,抽出自己的寶貴時間在此無私奉獻。編輯某些詞條時難免會有分歧,可以在有關詞條的討論頁上(點擊左上角的"討論本頁"即可進入)進行理智的討論,請文明用語。如需要刪除某頁面,請把 {{dlbc|请在此填写删除原因}} 置於需刪除頁面上。多謝您的合作!

最後祝我們合作愉快!讓我們一起編出一部一流的在線多語言詞典!

維基媒體非營利組織所承辦的其它項目


是歡迎您的維基人Shibo77 對話頁 13:51 2006年5月10日 (UTC)

  • 跨語言鏈接工作者請注意這裡按照ISO 639-3ISO 639-1國際標準的語言編碼字母順序。請將fi:芬蘭語鏈接置於fr:法語鏈接前。多謝您的合作!
  • Tiuj, kiuj faras interwiki ligilojn, bonvolu uzi la alfabetan ordon de lingvaj kodoj laŭ la internaciaj normoj ISO 639-3 k. ISO 639-1. Bonvolu fiksi la ligilon de la finna lingvo fi: antaŭ la ligilon de la franca lingvo fr:. Dankojn pro via kunlaboro!
  • Concerning those who do interwiki linking, please remember to use the alphabetical order of codes for languages as given in the international standards ISO 639-3 and ISO 639-1. Please place the Finnish language link fi: before the French language link fr:. Thank you for your cooperation!
Vi ne komprenas Ĉinan lingvon? Bonvolu fiksi {{User lang-0|zh}} sur via uzanta paĝo aŭ meti ĝin en via babela ŝablono.
Don't understand Chinese? Post {{User lang-0|zh}} on your user page or put it into your Babel box.

那我以後就在這給你回復了。。。

PiBot[編輯]

質量很差。。。 請問你用的是Windows吧?哪個版本?還有我可不可以在詞典那邊給你回復,我不常來百科。。。 --Shibo77 13:29 2006年5月10日 (UTC)

我用Linux,以前也用過Windows,大概是以下幾步,安裝python 2.4.3下載pywikipedia.py,創建用戶(試驗時也可以直接用User:Vipuser),用Notepad(Start>>Programs>>Accessories)復貼以下內容,存為user-config.py(也存在c:\pywikipedia里):
mylang = 'zh'
family = 'wiktionary'
usernames['wiktionary']['zh'] = 'Vipbot'
console_encoding = 'utf-8'

最後:Start>>Run>>cmd>>cd c:\pywikipedia>>login.py>>輸入你的密碼>>就可以運行了,你先想做什麼樣的工作? --Shibo77 13:48 2006年5月10日 (UTC)

成功了嗎?最初可以用interwiki.py(最簡單),接着上頭login.py>>輸入你的密碼>>interwiki.py。 --Shibo77 14:06 2006年5月10日 (UTC)
這我還不知道,用機器人還會被GFW擋住嗎? --Shibo77 14:08 2006年5月10日 (UTC)
這的內容(去掉"<pre></pre>")復貼到Notepad中,存為vip.txt(也在c:\pywikipedia里)。login.py>>輸入你的密碼>>pagefromfile.py -file:vip.txt -start:77 -end:88。就會自動生成新詞條了。用的時候在pagefromfile.py中加上底下這幾句:
msg={
    'de': u'Automatischer Import von Artikeln',
    'en': u'Automated import of articles',
    'ia': u'Importation automatic de articulos',
    'nl': u'Geautomatiseerde import',
    'zh': u'python程序: 自动引进/创建新条目'
    }

--Shibo77 14:14 2006年5月10日 (UTC)

對呀、設用代理後機器人同樣也用代理呀。。。 --Shibo77 14:17 2006年5月10日 (UTC)
   raise socket.error, msg

socket.error: (10060, 'Operation timed out')

可能得在login.py中做修改,不會是因為沒有授予bot權利,可以問一下User:Shizhao他有可能知道該怎麼做。。。--Shibo77 14:35 2006年5月10日 (UTC)

試試:export http_proxy="IP碼:80" login.py 有可能需要大寫HTTP_PROXY=
我先睡了,趕明再聊! --Shibo77 14:57 2006年5月10日 (UTC)
更改代理時必須得在根上做更改,Linux用Acquire::http::Proxy "IP码:8080",所有的信息就都引用代理了。從cmd上的dir里找出你的ipconfig,再把IP碼更改為代理地址。聽你說的瀏覽器可行而程序卻行不通很可能是因為你是用瀏覽器做的代理IP碼更改(因為程序是直接連上網的,不用瀏覽器)。可惜視窗Server 2003上具體該怎麼做我還是真的不會(大概是export HTTP_PROXY="IP码:80"),我再繼續調查調查。。。 --Shibo77 05:31 2006年5月12日 (UTC)
也可以更改你python程序的上網子程序httplib.py改成以下幾行試試:

(>>c: >>Python24>>Lib>>次鍵單擊httplib>>添加以下頭一行>>保存>>Start>>Run>>cmd>>cd c:\pywikipedia>>login.py>>輸入Vipbot的密碼>>pagefromfile.py -file:vip.txt -start:77 -end:88可以在詞典這邊運行,沒人在意Template:X;))

HTTP_PROXY = "在此输入你的代理IP码"
HTTP_PORT = 80
HTTPS_PORT = 443

試一試。別忘了用Notepad(Start>>Programs>>Accessories)復貼以下內容,存為user-config.py(也存在c:\pywikipedia里):

mylang = 'zh'
family = 'wiktionary'
usernames['wiktionary']['zh'] = 'Vipbot'
console_encoding = 'utf-8'

還有在pagefromfile.py中加上底下這幾句(>>c: >>pywikipedia>>次鍵單擊pagefromfile>>添加以下zh:一行,即编辑摘要显示):

msg={
    'de': u'Automatischer Import von Artikeln',
    'en': u'Automated import of articles',
    'ia': u'Importation automatic de articulos',
    'nl': u'Geautomatiseerde import',
    'zh': u'python程序: 自动引进/创建新条目'
    }

--Shibo77 09:19 2006年5月12日 (UTC)

我刚刚用145.97.39.130成功了!Template:X:D (我试用Windows XP) --Shibo77 09:24 2006年5月12日 (UTC)
============================================[編輯]
HTTP = "145.97.39.134"
HTTP_PORT = 80
HTTPS_PORT = 443

或有可能:

HTTP = "145.97.39.134:80"
HTTP_PORT = 80
HTTPS_PORT = 443

我写错了,再试试?(可惜我没法自己做试验) --Shibo77 10:55 2006年5月13日 (UTC)

=============================================[編輯]

把login.py改成:

#!/usr/bin/python
# -*- coding: utf-8  -*-
"""
Script to log the robot in to a wiki account.

Suggestion is to make a special account to use for robot use only. Make
sure this robot account is well known on your home wikipedia before using.

Parameters:

   -pass:XXXX   Uses XXXX as password. Be careful if you use this
                parameter because your password will be shown on your
                screen.
   
   -sysop       Log in with your sysop account.
   
   -all         Try to log in on all sites where a username is defined in
                user-config.py.
                
   -force       When doing -all, ignores if the user is already loged in,
                and tries to login for all listed sites.
                This may be useful if you have changed the account name
                and need to aquire new login cookies.

If not given as parameter, the script will ask for your username and password
(password entry will be hidden), log in to your home wiki using this
combination, and store the resulting cookies (containing your password hash,
so keep it secured!) in a file in the login-data subdirectory.

All bots in this library will be looking for this cookie file and will use the
login information if it is present.

To log out, throw away the XX-login.data file that is created in the login-data
subdirectory.
"""
#
# (C) Rob W.W. Hooft, 2003
#
# Distributed under the terms of the MIT license.
#
__version__='$Id: login.py,v 1.45 2006/03/03 16:51:20 a_engels Exp $'

import re, sys, getpass
import httplib, urllib2
import socket
import wikipedia, config

def makepath(path):
    """ creates missing directories for the given path and
        returns a normalized absolute version of the path.

    - if the given path already exists in the filesystem
      the filesystem is not modified.

    - otherwise makepath creates directories along the given path
      using the dirname() of the path. You may append
      a '/' to the path if you want it to be a directory path.

    from [email protected] 2002/03/18
    """
    from os import makedirs
    from os.path import normpath,dirname,exists,abspath

    dpath = normpath(dirname(path))
    if not exists(dpath): makedirs(dpath)
    return normpath(abspath(path))

class LoginManager:
    def __init__(self, password = None, sysop = False, site = None):
        self.site = site or wikipedia.getSite()
        if sysop:
            try:
                self.username = config.sysopnames[self.site.family.name][self.site.lang]
            except:
                raise wikipedia.NoUsername(u'ERROR: Sysop username for %s:%s is undefined.\nIf you have a sysop account for that site, please add such a line to user-config.py:\n\nsysopnames[\'%s\'][\'%s\'] = \'myUsername\'' % (self.site.family.name, self.site.lang, self.site.family.name, self.site.lang))
        else:
            try:
                self.username = config.usernames[self.site.family.name][self.site.lang]
            except:
                raise wikipedia.NoUsername(u'ERROR: Username for %s:%s is undefined.\nIf you have an account for that site, please add such a line to user-config.py:\n\nusernames[\'%s\'][\'%s\'] = \'myUsername\'' % (self.site.family.name, self.site.lang, self.site.family.name, self.site.lang))
        self.password = password

    def botAllowed(self):
        """
        Checks whether the bot is listed on Wikipedia:Bots to comply with
        the policy on the English and the Simple English Wikipedia.
        """
        if self.site in (wikipedia.getSite('en', 'wikipedia'), wikipedia.getSite('simple', 'wikipedia')):
            pl = wikipedia.Page(self.site, "Wikipedia:Bots")
            text = pl.get()
            return "[[user:%s" % self.username.lower() in text.lower()
        else:
            # No bot policies on other 
            return True
    
    def getCookie(self, remember=True):
        """Login to wikipedia.
    
        remember    Remember login (default: True)
        
        Returns cookie data if succesful, None otherwise."""
    
        data = {"wpName": self.username,
                "wpPassword": self.password,
                "wpLoginattempt": "Aanmelden & Inschrijven", # dutch button label seems to work for all wikis
                "wpRemember": str(int(bool(remember)))}
        data = wikipedia.urlencode(data.items())
        headers = {
            "Content-type": "application/x-www-form-urlencoded", 
            "User-agent": "RobHooftWikiRobot/1.0"
        }
        pagename = self.site.login_address()
        if self.site.hostname() in config.authenticate.keys():
            response = urllib2.urlopen(urllib2.Request('http://'+self.site.hostname()+pagename, data))
            data = response.read()
            wikipedia.cj.save(wikipedia.COOKIEFILE)
            return "Ok"
        else:
            conn = httplib.HTTPConnection("145.97.39.134:80")
            conn = httplib.HTTPConnection(self.site.hostname())
            conn.request("POST", pagename, data, headers)
            response = conn.getresponse()
            conn.close()

            data = response.read()
            n=0
            Reat=re.compile(': (.*?);')
            L = []

            for eat in response.msg.getallmatchingheaders('set-cookie'):
                m = Reat.search(eat)
                if m:
                    n += 1
                    L.append(m.group(1))

            if len(L) == 4:
                return "\n".join(L)
            else:
                return None

    def storecookiedata(self, data):
        """
        Stores cookie data.

        The argument data is the raw data, as returned by getCookie().

        Returns nothing."""
        filename = 'login-data/%s-%s-%s-login.data' % (self.site.family.name, self.site.lang, self.username)
        f = open(makepath(filename), 'w')
        f.write(data)
        f.close()

    def login(self, retry = False):
        if not self.password:
            # As we don't want the password to appear on the screen, we use getpass().
            s = u'Password for user %s on %s: ' % (self.username, self.site)
            self.password = getpass.getpass(s.encode(config.console_encoding))
            # Convert the password from the encoding your shell uses to the one your wiki
            # uses, via Unicode. This is the same as wikipedia.input() does with the 
            # username, but input() uses raw_input() instead of getpass().
            self.password = unicode(self.password, config.console_encoding)
    
        self.password = self.password.encode(wikipedia.myencoding())
    
        wikipedia.output(u"Logging in to %s as %s" % (self.site, self.username))
        # Ensure bot policy on the English Wikipedia
        if not self.botAllowed():
            wikipedia.output(u'*** Your username is not listed on [[Wikipedia:Bots]].\n*** Please make sure you are allowed to use the robot before actually using it!')
        cookiedata = self.getCookie()
        if cookiedata:
            self.storecookiedata(cookiedata)
            wikipedia.output(u"Should be logged in now")
            return True
        else:
            wikipedia.output(u"Login failed. Wrong password?")
            if retry:
                self.password = None
                return self.login(retry = True)
            else:
                return False

def main():
    username = password = None
    sysop = False
    logall = False
    forceLogin = False
    for arg in sys.argv[1:]:
        arg = wikipedia.argHandler(arg, 'login')
        if arg:
            if arg.startswith("-pass:"):
                password = arg[6:]
            elif arg == "-sysop":
                sysop = True
            elif arg == "-all":
                logall = True
            elif arg == "-force":
                forceLogin = True
            else:
                wikipedia.showHelp('login')
                sys.exit()
    if logall:
        if sysop:
            namedict = config.sysopnames
        else:
            namedict = config.usernames
        for familyName in namedict.iterkeys():
            for lang in namedict[familyName].iterkeys():
                site = wikipedia.getSite(code=lang, fam=familyName)
                if not forceLogin and site.loggedin(sysop = sysop):
                    wikipedia.output(u'Already logged in on %s' % site)
                else:
                    loginMan = LoginManager(password, sysop = sysop, site = site)
                    loginMan.login()
    else:
        loginMan = LoginManager(password, sysop = sysop)
        loginMan.login()

if __name__ == "__main__":
    try:
        main()
    finally:
        wikipedia.stopme()

试试。就是加了两行:import socketconn = httplib.HTTPConnection("145.97.39.134:80") --Shibo77 12:00 2006年5月14日 (UTC)