【问题标题】:How can i create a program based on a web page?如何基于网页创建程序?
【发布时间】:2019-11-02 04:01:37
【问题描述】:

我正在尝试创建一个基于 WhatsApp 网络应用程序的程序。我试图找出启动此类程序的最佳编程语言。例如,我用 java 尝试过,但使用这个实现:


    public UrlReader() throws IOException {

            try {
                URL whatsApp = new URL("https://web.whatsapp.com/");
                DataInputStream dis = new DataInputStream(whatsApp.openStream());
                String inputLine;

                while ((inputLine = dis.readLine()) != null) {
                    System.out.println(inputLine);
                }
                dis.close();
            } catch (MalformedURLException me) {
                System.out.println("MalformedURLException: " + me);
            } catch (IOException ioe) {
                System.out.println("IOException: " + ioe);
            }
        }

这只是来自 oracle 网站的基本复制和粘贴。这个程序的输出是一个网站,告诉我我必须使用像 chrome 这样的浏览器。有没有更好的方法来创建这样的程序?

【问题讨论】:

  • "[B]ased on" 可能意味着很多事情。 有什么想法?
  • 我想输入 html 以详细说明其中包含的信息。

标签: java html web-applications


【解决方案1】:

您可以从 Python 开始玩 web.whatsapp.com。我假设您正在尝试使用代码在 WhatsApp 上发送消息。

在 Python 中,您可以像使用 mobile application 一样进行操作

 web.open('https://web.whatsapp.com/send?phone='+phone_no+'&text='+message)

这将预先填充给定手机号码的文本(输入 phone_no 作为 CountryCode 和号码,例如 +918888888888) 然后使用 pyautogui 你可以按回车键进入 whatsapp.web

工作代码:

def sendwhatmsg(phone_no, message, time_hour, time_min):
     '''Sends whatsapp message to a particulal number at given time'''
     if time_hour == 0:
         time_hour = 24
     callsec = (time_hour*3600)+(time_min*60)

     curr = time.localtime()
     currhr = curr.tm_hour
     currmin = curr.tm_min
     currsec = curr.tm_sec

     currtotsec = (currhr*3600)+(currmin*60)+(currsec)
     lefttm = callsec-currtotsec

     if lefttm <= 0:
         lefttm = 86400+lefttm

     if lefttm < 60:
         raise Exception("Call time must be greater than one minute")

     else:
         sleeptm = lefttm-60
         time.sleep(sleeptm)
         web.open('https://web.whatsapp.com/send?phone='+phone_no+'&text='+message)
         time.sleep(60)
         pg.press('enter')

我从这个存储库中获取了这个 - Github repo

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-06
    • 1970-01-01
    • 2019-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多