Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
working with lxml and requests
#7
So after looking over your links here is what I have now...

import requests
from bs4 import BeautifulSoup

response = requests.get('https://10.10.10.1/vmrest/users?rowsPerPage=2000\&pageNumber=1', verify=False, auth=('user', 'pass'))

soup = BeautifulSoup(response.content, 'html.parser')
print(soup.find('title').text)
and I get the following output...

Error:
Warning (from warnings module): File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 845 InsecureRequestWarning) InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings Cisco System - Error report
It does support GET. There is an old perl script that uses GET to do the same thing, however, the old script doesnt work on a new Debian server and none of us know Perl, just basic Python for scripting access to routers and switches. The perl script uses the following modules...
LWP::UserAgent
XML::Simple

The code in perl looks like this...

use LWP::Simple;
use XML::Simple;

my $xml = new XML::Simple;
my @userdata;

$page = 1;

while(1)
{ 
  my $url = "https://USER:pass\@10.10.10.1/vmrest/users?rowsPerPage=2000\&pageNumber=$page";
  my $content = get($url);
  die "error getting $url" unless defined $content;

  my $data = $xml->XMLin($content);

# if we dont get at least one user end loop

  if(@{$data->{User}} < 1)
{
  last;
}
# build the userdata array, each entry contains "username,extension"

$start =(($page-1) * 2000);
for ($i=$start;$i<=$start + @{$data->{User}} - 1;$i++)
{
  push(@userdata,"$data->{User}->[$i-$start]->{Alias},$data->{User}->[$i-$start]->{DtmfAccessId}");
 }
$page++

# Dump the results to a file

open(UNITY,"/usr/scripts/unityLDAP/$timestamp-unity.csv");
for(@userdata)
 {
 print UNITY "$_\n";
}
close(UNITY);
Reply


Messages In This Thread
working with lxml and requests - by gentoobob - Apr-18-2018, 02:47 PM
RE: working with lxml and requests - by nilamo - Apr-18-2018, 03:04 PM
RE: working with lxml and requests - by gentoobob - Apr-18-2018, 04:43 PM
RE: working with lxml and requests - by Larz60+ - Apr-18-2018, 05:07 PM
RE: working with lxml and requests - by gentoobob - Apr-18-2018, 05:16 PM
RE: working with lxml and requests - by nilamo - Apr-18-2018, 05:52 PM
RE: working with lxml and requests - by gentoobob - Apr-18-2018, 06:16 PM
RE: working with lxml and requests - by nilamo - Apr-18-2018, 06:53 PM
RE: working with lxml and requests - by gentoobob - Apr-18-2018, 07:30 PM
RE: working with lxml and requests - by nilamo - Apr-18-2018, 07:35 PM
RE: working with lxml and requests - by snippsat - Apr-18-2018, 08:08 PM
RE: working with lxml and requests - by nilamo - Apr-18-2018, 08:15 PM
RE: working with lxml and requests - by gentoobob - Apr-18-2018, 08:21 PM
RE: working with lxml and requests - by snippsat - Apr-18-2018, 08:27 PM
RE: working with lxml and requests - by snippsat - Apr-18-2018, 10:48 PM
RE: working with lxml and requests - by gentoobob - Apr-19-2018, 01:08 PM
RE: working with lxml and requests - by snippsat - Apr-19-2018, 01:36 PM
RE: working with lxml and requests - by gentoobob - Apr-19-2018, 01:39 PM
RE: working with lxml and requests - by nilamo - Apr-19-2018, 02:44 PM
RE: working with lxml and requests - by gentoobob - Apr-19-2018, 04:41 PM
RE: working with lxml and requests - by snippsat - Apr-19-2018, 05:17 PM
RE: working with lxml and requests - by gentoobob - Apr-19-2018, 05:43 PM
RE: working with lxml and requests - by snippsat - Apr-19-2018, 06:49 PM
RE: working with lxml and requests - by gentoobob - Apr-19-2018, 06:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  POST requests - different requests return the same response Default_001 3 1,998 Mar-10-2022, 11:26 PM
Last Post: Default_001
  requests module is not working varsh 3 3,880 Sep-10-2020, 03:53 PM
Last Post: buran
  Flask, Posgresql - Multiple requests are not working bmaganti 5 2,839 Feb-20-2020, 03:02 PM
Last Post: bmaganti
  [Help]xpath is not working with lxml mr_byte31 3 6,329 Jul-22-2018, 04:10 PM
Last Post: stranac

Forum Jump:

User Panel Messages

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