I'm currently planning to create a small package to enable Mathematica to manipulate WeChat, a extremely famous chatting software in China.

The first step is to get the QRCode on the website, but the QR is automatically updated once a few minute and use AJAX, so a direct URLFetch or Import won't work, also Import["https://wx.qq.com/","JSON"] failed on my computer too.

I can get a proper HTML result using the developer tool on my web browser: proper

But the automatically updated QRCode address part(the selected region on the previous screenshot) cannot be fetched by Mathematica easily (due to AJAX)

not good

The QRCode address part of this small HTML segment is replaced.

So how can I get a HTML result just like what I get in my web browser regardless of all AJAX or other stuffs? Thanks!


There're existing packages in Python: itchat

How to execute JavaScipt on a webpage and then import the result on OSX? (note that the method given in this question cannot solve my problem, even though I use windows os)

  • $\begingroup$ The only way to generate the HTML you see in a browser is to actually evaluate the website source code as a browser. WebUnit can maybe be used, but I've never used it so I'm not sure. I talked here about using Chrome's developer tool to find out where the data is coming from. The idea is to use that, and then download the data from there directly. $\endgroup$
    – C. E.
    Commented Jun 4, 2017 at 5:51
  • $\begingroup$ It's not clear to me which JSON file you are trying to import, in your case it seems that you are wanting to find the URL of an image? $\endgroup$
    – C. E.
    Commented Jun 4, 2017 at 12:09
  • $\begingroup$ @C.E. yup, and in further cases maybe I will need to fetch some other contents, e.g. messages and links. so the main goal is to fetch the HTML. That comment is useless, sorry...... I misunderstood your post $\endgroup$
    – Wjx
    Commented Jun 4, 2017 at 12:53


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.