【问题标题】:Access forms from another website using NodeJS使用 NodeJS 从另一个网站访问表单
【发布时间】:2020-06-06 02:49:35
【问题描述】:

如何使用 NodeJS 更新其他人网站上的表单?

示例)一个论坛网站可以让你在没有帐户的情况下发帖,我如何使用 nodeJS 将我想要发布的内容写成字符串,然后使用 nodeJS 将其提交到论坛?

来自第三方网站的代码示例:

<form id="msg" class=" msgc" method="post" action=" " enctype="multipart/form-data">
<input type="text" id="texter" />
<input type="submit" id="submitter" />
</form>

【问题讨论】:

标签: javascript node.js forms web-scraping


【解决方案1】:

您可以使用 Axios 和发布请求。无论如何,如果他们正确设置了 CORS 政策,我认为它实际上不会起作用。

axios.post('/user', {
firstName: 'Fred',
lastName: 'Flintstone'
 })
     .then(function (response) {
     console.log(response);
})
     .catch(function (error) {
     console.log(error);
});

Axios

【讨论】:

  • 谢谢,我决定改用 python,因为它为项目带来了更多收益。但我测试了你的答案,它是正确的。感谢您的帮助。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-10-06
  • 2017-05-06
  • 2019-11-11
  • 1970-01-01
  • 2016-07-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多