I've started to learn to use axios to post form data to a website but every time i run the code from the command line i am given 'Error: Request failed with status code 406'. Since i am only a beginner when it comes to axios I am not too sure whether it is my code that is wrong or, if the website i am sending the post request to is purposely throttling my code in an attempt to stop bots on the website. If it is the latter, how can i get around this? I have already tried changing my user agent to the chrome user agent & it doesn't seem to do anything.This is the code:const url = 'https://titolo.us6.list-manage.com/subscribe/post?u=652f80ec0adf2d7ac9588d0a1&id=ac55c249f8' axios.post(url, new URLSearchParams( { EMAIL: 'youremail@email.com', //test code here FNAME: 'yourname', LNAME: 'yoursurname', // Address MMERGE: '123 road street', // Postcode MMERGE8: 'eg:SW1A 1AA', // City MMERGE12: 'City', // Country MMERGE3: 'United Kingdom', PHONE: '441234567890', // Gender MMERGE9: 'Male', // Language MMERGE10: 'en', // Size MMERGE6: 'UK 9 (43 1/3)', // Instagram account name MMERGE7: 'some instagram account', // T&Cs 'group[243][1]': '1', // That invisible input b_652f80ec0adf2d7ac9588d0a1_8093f364b8: '', // Subscribe button subscribe: 'Subscribe' }, {headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36' } } ) ).then(res => console.log(res)) .catch((res) => { console.error(res); });
Submitted September 03, 2020 at 04:23PM by Winner-Popular
No comments:
Post a Comment