Git Product home page Git Product logo

Comments (10)

littlecodersh avatar littlecodersh commented on May 28, 2024

@9cat 再次运行程序还是失败吗?

from itchat.

9cat avatar 9cat commented on May 28, 2024

@littlecodersh 是的, 是需要修改appid之类的吗? 另外,我不在**境内, 会有影响吗?

from itchat.

littlecodersh avatar littlecodersh commented on May 28, 2024

@9cat 你能够正常登陆网页版微信吗?

from itchat.

9cat avatar 9cat commented on May 28, 2024

可以的, 出现:
image

from itchat.

littlecodersh avatar littlecodersh commented on May 28, 2024

试试看这个测试程序:

import requests, itchat, platform, subprocess, os

uuid = itchat.get_QRuuid()
url = '%s/qrcode/%s'%('https://login.weixin.qq.com', uuid)
r = requests.get(url, stream = True)
QR_DIR = 'QR.jpg'
with open(QR_DIR, 'wb') as f: f.write(r.content)
if platform.system() == 'Darwin':
    subprocess.call(['open', QR_DIR])
elif platform.system() == 'Linux':
    subprocess.call(['xdg-open', QR_DIR])
else:
    os.startfile(QR_DIR)

from itchat.

9cat avatar 9cat commented on May 28, 2024

出现找不到文件: (不过我在目录中倒是看到QR.jpg , 另外,我用的是VPS,console, 应该没法直接打开QR.jpg)

Traceback (most recent call last):
  File "test3.py", line 11, in <module>
    subprocess.call(['xdg-open', QR_DIR])
  File "/usr/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

我用cacaview 看QR.jpg
image

from itchat.

littlecodersh avatar littlecodersh commented on May 28, 2024

@9cat 那就需要找一个方法显示二维码,我这里有一个基础的解决方案:这里

from itchat.

9cat avatar 9cat commented on May 28, 2024

我这样就能显示了, 加了一个 ”./ “

import requests, itchat, platform, subprocess, os

uuid = itchat.get_QRuuid()
url = '%s/qrcode/%s'%('https://login.weixin.qq.com', uuid)
r = requests.get(url, stream = True)
QR_DIR = "./QR.jpg"

print uuid
with open(QR_DIR, 'wb') as f: f.write(r.content)


print QR_DIR
if platform.system() == 'Darwin':
    subprocess.call(['open', QR_DIR])
elif platform.system() == 'Linux':
    subprocess.call(['cacaview', QR_DIR])
else:
    os.startfile(QR_DIR)

from itchat.

9cat avatar 9cat commented on May 28, 2024

这个QRCODE 显示有意思:

import requests, itchat, platform, subprocess, os

from PIL import Image
import sys

BLOCK = 'MM'
class QRCode():
    def __init__(self, fileName, size, padding = 0, background = 'BLACK'):
        self.size = size
        self.padding = padding
        self.img = Image.open(fileName)
        self.times = self.img.size[0]/(size + padding * 2)
        self.rgb = self.img.convert('RGB')
        self.white = BLOCK if background == 'BLACK' else '  '
        self.black = '  ' if background == 'BLACK' else BLOCK
    def print_qr(self):
        sys.stdout.write(' '*50 + '\r')
        sys.stdout.flush()
        print(self.white * (self.size + 2))
        startPoint = self.padding + 0.5
        for y in range(self.size):
            sys.stdout.write(self.white)
            for x in range(self.size):
                r,g,b = self.rgb.getpixel(((x + startPoint) * self.times, (y + startPoint) * self.times))
                sys.stdout.write(self.white if r > 127 else self.black)
            print(self.white)
        print(self.white * (self.size + 2))


uuid = itchat.get_QRuuid()
url = '%s/qrcode/%s'%('https://login.weixin.qq.com', uuid)
r = requests.get(url, stream = True)
QR_DIR = './QR.jpg'

print uuid
with open(QR_DIR, 'wb') as f: f.write(r.content)

print QR_DIR
if platform.system() == 'Darwin':
    subprocess.call(['open', QR_DIR])
elif platform.system() == 'Linux':
#    subprocess.call(['cacaview', QR_DIR])
    q =  QRCode(QR_DIR, 37, 3, 'BLACK')
    q.print_qr()
else:
    os.startfile(QR_DIR)

from itchat.

9cat avatar 9cat commented on May 28, 2024

@littlecodersh 感谢, 大功告成! 能自动回复所以有信息了。

from itchat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.