I try to upload to file hosting, i debug it in firebug. i match all thing with disable javascript condition. it return empty data. in debug, it should return page that contain the file link.
const axios = require('axios').default;
const fs = require('fs');
const FormData = require('form-data');
let formData = new FormData();
formData.append('file_0', fs.readFileSync('filepath');
const fileSize = fs.statSync('filepath').size;
const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36';
axios({
method: 'post',
url: 'https://www55.zippyshare.com/upload',
headers: {
'user-agent': userAgent,
'content-length': fileSize,
'host': 'www55.zippyshare.com',
'origin': 'https://www.zippyshare.com',
'referer': 'https://www.zippyshare.com/',
'connection': 'keep-alive',
'content-type': 'multipart/form-data',
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8'
},
data: formData
}).then(res => {
console.log(res.data)
})
I use Replit Nodejs
thats about dlive bot, The resource I found about the dlive api was very insufficient for me, so I am having a hard time.
async function sendMessage(message){
let url = 'https://graphigo.prd.dlive.tv'
let headers = {
'accept': '*/*',
'authorization': authKey,
'content-type': 'application/json',
'fingerprint': '',
'gacid': 'undefined',
'Origin': 'https://dlive.tv',
'Referer': 'https://dlive.tv/'+displayname,
'User-Agent':
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'
}
let data = {
'operationName': 'SendStreamChatMessage',
'variables': { "input":
{
'streamer': blockchainUsername,
'message': message,
'roomRole': 'Moderator',
'subscribing': true
}
},
'extensions':{
"persistedQuery":{
"version":1,
"sha256Hash":Hash
}
},
}
response = await axios.post(url, data=JSON.stringify(data), headers=headers)
console.log(response.data)
}
sendMessage("test!")
Console:
{ errors: [ { message: 'Require login', path: [Array] } ], data: null }
I am sending this from my react frontend to my node backend
const data = await axios.post('http://localhost:5000/api/login', {email, password}, {
headers:{
'Authorization':'somesecretkey'
}
});
Where I am trying to accept headers like this
const { headers } = req;
console.log(headers);
but i am getting this
{
host: 'localhost:5000',
connection: 'keep-alive',
'content-length': '54',
'sec-ch-ua': '" Not;A Brand";v="99", "Microsoft Edge";v="91", "Chromium";v="91"',
accept: 'application/json, text/plain, */*',
'sec-ch-ua-mobile': '?0',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36 Edg/91.0.864.59',
'content-type': 'application/json;charset=UTF-8',
origin: 'http://localhost:3000',
'sec-fetch-site': 'same-site',
'sec-fetch-mode': 'cors',
'sec-fetch-dest': 'empty',
referer: 'http://localhost:3000/',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-US,en;q=0.9'
}
that is i am not getting any Authorisation header in backend.
What i am doing wrong?
I'm using request.
I want to login a website only once, then use the same connection until it expires, so I won't have to login every time I send a request.
How can I do that?
I have tried the code below, but it doesn't retain the session. I'm using Redis to save cookie values, this is probably the wrong way, though. Two cookies are generated after you log in.
var request = require("request").defaults({jar: true, followAllRedirects: true});
var options1 = {
method: 'GET',
url: 'homepageURL',
headers:
{
'cache-control': 'no-cache',
'accept-language': 'tr,en-US;q=0.9,en;q=0.8,ru;q=0.7,it;q=0.6,fr;q=0.5,de;q=0.4,es;q=0.3,sv;q=0.2,nl;q=0.1,pl;q=0.1,pt;q=0.1,nb;q=0.1',
'accept-encoding': 'gzip, deflate, br',
referer: 'URL',
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36',
'upgrade-insecure-requests': '1'
}
};
request(options1, function (homeError, homeResponse, homeBody) {
if (homeResponse.statusCode == 200) {
var form = {"username": "myusername", "password": "mypassword", "secret": "mysecret", "action": "login"};
var options2 = {
method: 'POST',
url: 'siteurl + "/" + login.asp',
headers:
{
'cache-control': 'no-cache',
'accept-language': 'tr,en-US;q=0.9,en;q=0.8,ru;q=0.7,it;q=0.6,fr;q=0.5,de;q=0.4,es;q=0.3,sv;q=0.2,nl;q=0.1,pl;q=0.1,pt;q=0.1,nb;q=0.1',
'accept-encoding': 'gzip, deflate, br',
referer: 'URL',
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36',
'content-type': 'application/x-www-form-urlencoded',
'upgrade-insecure-requests': '1',
origin: url + "/" + login.asp
},
form: form
};
request(options2, function (loginError, loginResponse, loginBody) {
if (loginResponse.statusCode == 200) {
console.log("Successfully logged in.");
client.set("cookie1", homeResponse.request.headers.cookie, function () {
client.set("cookie2", loginResponse.request.headers.cookie, function () {
nrp.emit('profile', {});
});
});
}
});
}
});
Profile test
nrp.on('profile', function () {
client.get("cookie1", function (cookie1Err, cookie1) {
client.get("cookie2", function (cookie2Err, cookie2) {
var cookie = cookie1 + ";" + cookie2;
var options = {
method: 'GET',
url: 'site/profile',
headers:
{
'cookie': cookie,
'accept-language': 'tr,en-US;q=0.9,en;q=0.8,ru;q=0.7,it;q=0.6,fr;q=0.5,de;q=0.4,es;q=0.3,sv;q=0.2,nl;q=0.1,pl;q=0.1,pt;q=0.1,nb;q=0.1',
'accept-encoding': 'gzip, deflate, br',
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36',
'upgrade-insecure-requests': '1'
}
};
request(options, function (error, response, body) {
console.log(body);
// it says you are not logged in, but if you use this inside the block above, it works.
});
})
});
});
How can I send both query string parameters and form data parameters in nodejs. I tried the following code. but it's not working. it is just hanging and no response is comming.
var url_req = require("request");
url_req({
pool: separateReqPool,
url: "https://somthing.com/v1/message/userF",
method: 'POST',
qs: {
action: "send-message",
c: "somecode_c",
cache: new Date().getTime(),
sid: "somecode_sid"
},
form: {
convId: "userF~userT~esp",
message: "<font face='Arial' size='10'>.</font>",
sendAs: "userF",
txnId: "userF~" + new Date().getTime() + "~number",
},
headers: {
'Content-Type': 'application/json;charset=utf-8',
'Cookie': 'some cookies',
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:33.0) Gecko/20100101 Firefox/33.0',
'Accept-Language': "en-US,en;q=0.5",
'Connection': "keep-alive",
'Pragma': "no-cache",
'Cache-Control': "no-cache",
'Referer': "https://something.com/xframe.html?bc",
'Accept': ' text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Content-Length': 100,
'Host': "something.com"
}
}, function (error, response, body) {
if (error)
console.log(error);
else
console.log(body);
});