I was trying to scrape search results from DDG the other day, but i keep getting response 418. How can i make it response 200 or get results from it? This is my code.
import requests
from bs4 import BeautifulSoup
import urllib
while True:
query = input("Enter Search Text: ")
a = query.replace(' ', '+')
url = 'https://duckduckgo.com/?q=random' +a
headers = {"User-Agent": "Mozilla/5.0 (Linux; Android 6.0.1; SHIELD Tablet K1 Build/MRA58K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/55.0.2883.91 Safari/537.36"}
r = requests.get(url)
print(r)
soup = BeautifulSoup(r.content,'lxml')
tags = soup.findAll('h2', class_="result__title")
print(tags)```