Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with python3 (BeautifulSoup)
#1
import requests
from termcolor import *
import colorama
from bs4 import BeautifulSoup
colorama.init()
headers = {
	"Cookie": "PHPSESSID=Testing",
	"User-Agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36"
}

url = "http://naruto.lt/kovos.php?kur=mob&kas=kzm_Futa%20Kagetsu"
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.content, 'html.parser')
r.content shows link (http://naruto.lt/kovos.php?kur=begin&ref=[GENERATING RANDOM NUMBERS]&kas=kzm_Futa%20Kagetsu) how i can get $_GET['ref'] ? i tried to do in many ways but nothing worked

sorry for bad english
Reply
#2
1st you should modify:
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.content, 'html.parser')
to
response = requests.get(url, headers=headers)
if response.status_code == 200:
    soup = BeautifulSoup(response.content, 'html.parser')
    links = soup.find_all('a')
    for link in links:
        print(link.get('href'))
        print(link.text)
else:
    print('Unable to open URL: {}'.format(url))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Need help to get product details using BeautifulSoup+Python3.6! PrateekG 2 2,835 Jun-27-2018, 08:52 AM
Last Post: PrateekG
  Unable to fetch product url using BeautifulSoup with Python3.6 PrateekG 6 4,140 Jun-05-2018, 05:49 PM
Last Post: PrateekG

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020