与网页连接并从中获取返回值 [英] Interfacing with, and getting return values from, a webpage

查看:119
本文介绍了与网页连接并从中获取返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个程序,我需要与网页连接 - 网页将

接受一个输入(可能是一个''post''字符串来自程序)然后将

处理它并需要返回一个值。是否有一种简单的方法来接口

程序来执行此操作?我有两个问题:

如何在c / c ++中尽可能简单地调用网页(最好不要使用MFC等来支付
)并传递''post''字符串到页面?

如何检索网页输出的值数组?我可以用我喜欢的任何格式输出

它们因为我也在编写网页 - 我在想 -

只是将输出页面写成变量列表,基本上以动态

生成逗号分隔值数据,但我不确定这是否更简单或更快捷的方式。任何想法?

作为一个补充点,我不想实际打开网页,因此它是可见的 - 它应该保持隐藏,所以用户是节目不知道

它在那里。


非常感谢


David

Hi
I have a program which I need to interface with a webpage - the webpage will
accept an input (probably a ''post'' string from the program) and then will
process it and needs to return a value. Is there an easy way to interface
the program to do this? I have two questions:
How can I call a webpage as simply as possible in c / c++ (preferably not
using MFC etc) and pass a ''post'' string to the page?
How can I retrieve an array of values output by the webpage? I can output
them in any format I like since i''m writing the webpage too - I was thinking
just write the output page as a list of variables, basically as dynamically
generated comma separated values data, but i''m not sure whether theres an
easier or quicker way of doing it. Any ideas?
As an added point, I don''t want to actually open the webpage so that it is
visible - it should remain hidden, so the user of the program is not aware
of it being there.

Thanks a lot

David

推荐答案

David Walker写道:
David Walker wrote:
我有一个程序,我需要与网页连接 - 网页将<接受输入(可能是程序中的''post''字符串)然后将处理它并需要返回一个值。是否有一种简单的方法来连接程序来执行此操作?我有两个问题:


如何在c / c ++中尽可能简单地调用网页(最好不要使用MFC等)并传递''post''字符串到页面?


[从comp.lang.c发布]


你不能在标准C中这样做 - 所以这个讨论是关闭的 - 话题

。您需要在特定于您的平台的新闻组中询问此问题,并询问您的客户端与

网络的接口。我不认为在服务器端需要做任何特殊的事情,而不是确保有一个

HTML(或者可能是纯文本)要检索的文件。

如何检索网页输出的值数组?我可以用我喜欢的任何格式输出它们,因为我也在编写网页 - 我在想
只是把输出页面写成变量列表,基本上就像动态生成逗号一样分开的值数据,但我不确定是否更容易或更快的方式。有任何想法吗?


只需使用您的

平台提供的机制发出HTTP请求。它在POSIX环境中很容易 - 但是可能会或者可能不会在Windows中使用
(我不知道)。

作为补充一点,我不喜欢我不想实际打开网页以使其可见 - 它应该保持隐藏状态,因此程序的用户不知道它在那里。
I have a program which I need to interface with a webpage - the webpage will
accept an input (probably a ''post'' string from the program) and then will
process it and needs to return a value. Is there an easy way to interface
the program to do this? I have two questions:
How can I call a webpage as simply as possible in c / c++ (preferably not
using MFC etc) and pass a ''post'' string to the page?
[Posting from comp.lang.c]

You can''t do this in standard C - so this discussion is off-topic
here. You need to ask this question in a newsgroup specific to
your platform and ask about interfacing your client to the
network. I don''t think there''s anything special that needs to be
done on the server side other than to make sure that there''s an
HTML (or possibly plain text) file to retrieve.
How can I retrieve an array of values output by the webpage? I can output
them in any format I like since i''m writing the webpage too - I was thinking
just write the output page as a list of variables, basically as dynamically
generated comma separated values data, but i''m not sure whether theres an
easier or quicker way of doing it. Any ideas?
Just issue an HTTP request using that mechanism provided by your
platform. It''s easy in a POSIX environment - but may or may not
be in Windows (I don''t know).
As an added point, I don''t want to actually open the webpage so that it is
visible - it should remain hidden, so the user of the program is not aware
of it being there.




这应该让工作变得轻松。祝好运。请记得从进一步讨论中删除

comp.lang.c。

-

Morris Dovey

West美国爱荷华州得梅因

C链接在 http:// www。 iedu.com/c



This should make the job easy. Good luck. Please remember to drop
comp.lang.c from further discussion.
--
Morris Dovey
West Des Moines, Iowa USA
C links at http://www.iedu.com/c


[后续设置为comp.programming,因为这不是语言问题]


David Walker写道:
[follow-ups set to comp.programming since this isn''t a language question]

David Walker wrote:

我有一个程序,我需要与网页连接 - 网页将接受
输入(可能是程序中的''post''字符串)然后将处理它并需要返回一个值。是否有一种简单的方法来连接程序来执行此操作?我有两个问题:
如何在c / c ++中尽可能简单地调用网页(最好不要使用MFC等)并将'post字符串传递给页面?


可能存在用于发出HTTP请求的库。如果你能找到一个你喜欢它的b $ b,那么你将节省大量的时间和精力。


否则...阅读在套接字和HTTP上。有很多套接字

教程,RFC2616中详细记录了HTTP协议。


最经常引用的网络教程可能有所帮助: > http: //www.ecst.csuchico.edu/~beej/g...tml/index.html

如何检索网页输出的值数组?我可以用我喜欢的任何格式输出它们,因为我也在编写网页 - 我在想
只是把输出页面写成变量列表,基本上就像动态生成逗号一样分开的值数据,但我不确定是否更容易或更快的方式。任何想法?
Hi
I have a program which I need to interface with a webpage - the webpage will
accept an input (probably a ''post'' string from the program) and then will
process it and needs to return a value. Is there an easy way to interface
the program to do this? I have two questions:
How can I call a webpage as simply as possible in c / c++ (preferably not
using MFC etc) and pass a ''post'' string to the page?
There may be libraries around for making HTTP requests. If you can find
one that you like it''ll save you a lot of time and effort doing it yourself.

Otherwise... read up on sockets and HTTP. There are a number of sockets
tutorials around, and the HTTP protocol is well documented in RFC2616.

The most often-quoted networking tutorial might help:

http://www.ecst.csuchico.edu/~beej/g...tml/index.html
How can I retrieve an array of values output by the webpage? I can output
them in any format I like since i''m writing the webpage too - I was thinking
just write the output page as a list of variables, basically as dynamically
generated comma separated values data, but i''m not sure whether theres an
easier or quicker way of doing it. Any ideas?




如果页面不是设计为浏览器查看,那么它不需要
需要是网页都没有。一个HTTP服务器非常能够返回一个文本文件,如果你用CGI支持这个,那么你可以把你想要的任何文本输出到客户端。然后你的
程序可以像处理任何文本文件一样处理该文本。


或者你可以在HTTP查询字符串中有一个变量

告诉CGI应用程序以特定格式生成输出,如果变量不存在或无效,则回退

到可显示的HTML。


-

Corey Murtagh

电僧

Quidquid latine dictum sit,altum viditur!



If the page is not designed to be viewed by a browser, then it doesn''t
need to be a web page at all. An HTTP server is quite capable of
returning a text document, and if you''re backing this with a CGI then
you can just pump whatever text you like out to the client. Your
program can then just process that text as you would any text file.

Alternately you could have a variable in the HTTP query string which
tells the CGI app to produce output in a specific format, with fallback
to displayable HTML if the variable is not present or invalid.

--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"


David Walker写道:
David Walker wrote:

我有一个程序需要与网页连接 -
网页将接受输入(可能是来自
程序的''post''字符串)然后将处理它并需要返回一个值。
是否有一种简单的方法来连接程序来执行此操作? [snip]

I have a program which I need to interface with a webpage - the
webpage will accept an input (probably a ''post'' string from the
program) and then will process it and needs to return a value.
Is there an easy way to interface the program to do this? [snip]




以下查询及其返回值应解释为什么这个

是c.l.c上的OT。 FUP设置。


[1] c:\c\malloc> grep -i -c网页\stds\\\
869.txt

0


-

Chuck F(cb********@yahoo.com)(cb ******** @ worldnet.att.net)

适用于咨询/临时嵌入式和系统。

< http://cbfalconer.home.att.net>使用worldnet地址!



The following query and its returned value should explain why this
is OT on c.l.c. FUPs set.

[1] c:\c\malloc>grep -i -c webpage \stds\n869.txt
0

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!


这篇关于与网页连接并从中获取返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆