Jump to content

bschultz

Members
  • Posts

    486
  • Joined

  • Last visited

Everything posted by bschultz

  1. Maxxd, when using a browser, there is a button to press to go from page 1 to page 2. This button is just a link, so the second curl request uses this link as the URL. Using Firefox Developer Tools - Network, page #4 makes two GET calls to two other pages (which includes the SQL Selects), then the content loads on page #4 Here are the two external page requests curl 'http://209.151.229.186/AffWeb_USRN/V2/ASP/GTD.asp?SQLCMD=spGetStationOptions%20%27WBJI-FM%27,%20%27Virtual%20News%20Network%20MF%27,%20%2710/19/2020%27,%20%2710/19/2020%27&DT=1603034713365' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://209.151.229.186/AffWeb_USRN/V2/log_exact.asp?startDate=10/19/2020&endDate=10/19/2020&SD=10/19/2020&ED=10/19/2020&gsfCode=0' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Connection: keep-alive' -H 'Cookie: SavePW=1; Password=xxxx; ASPSESSIONIDAARTRTBC=EAPNEIJAHEJILFGECNDAKNPE; ASPSESSIONIDQSBQTQDD=HNHHELCCMPNLDFACKGPLCJHF' curl 'http://209.151.229.186/AffWeb_USRN/V2/ASP/GTD.asp?SQLCMD=spGetAllSpots%20%27WBJI-FM%27,%20%27Virtual%20News%20Network%20MF%27,%20%2710/19/2020%27,%20%2710/19/2020%27&DT=1603034713563' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0' -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H 'Referer: http://209.151.229.186/AffWeb_USRN/V2/log_exact.asp?startDate=10/19/2020&endDate=10/19/2020&SD=10/19/2020&ED=10/19/2020&gsfCode=0' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Connection: keep-alive' -H 'Cookie: SavePW=1; Password=xxxx; ASPSESSIONIDAARTRTBC=EAPNEIJAHEJILFGECNDAKNPE; ASPSESSIONIDQSBQTQDD=HNHHELCCMPNLDFACKGPLCJHF' I can generate a temp password if someone want to use a browser to see what's happening...just private message me for the login details. Thanks!
  2. 4 pages deep means login page (page 1). Simulate a link click to page 2. Simulate a link click to page 3. Simulate a link click to page 4. Pages 2 and 3 have no javascript or Ajax coding. Page 4 does! Pages 2 and 3 have some coding that is tied to the login to display certain info. As far as I can tell, page 4 uses AJAX to set some database calls...thus without the AXAX info passed via CURL, I get AJAX:0 error. I'm assuming the AJAX:0 error is in the code of the page...but when I visit that page via a browser, it works...so no error. What code would you like me to post? Page 1, 2, 3, or 4?
  3. I'm trying to login and scrape a page 4 pages deep. I can get to the fourth page...but that page only returns AJAX ERROR:0. I know NOTHING about AJAX calls via Curl. Can someone please help me with what to look for in the source code of the 4th page (when using a browser) to what I'm supposed to pass along via CURL? If you need the source code or login credentials to see what's happening in the background, I can generate a temp password for you. Thanks!
  4. Upon further investigation, there is a cookie being set by a JQuery script...which in turn sets the rowid. So, how can I get CURL to interact with Java? Headless browser? I've never had much success with headless browsers before. Any tips? Thanks!
  5. But the rowid isn't set until you submit the form...so parse-url returns NULL. The flow of the login is: login page -> formprocessing page -> landing page. In the script, I'm sending a POST to the form processing page. Once that is done, the form processing page sets the rowid. I can see the rowid in my browser, but CURL doesn't know that value.
  6. My real job is as a radio announcer. We are required to play advertising commercials for various programs that we broadcast. I wrote a script a few years ago to automatically login to the providers website (PHP, Curl) and download the mp3's that we are supposed to play each day. Now, the provider has updated their website and changed the login process. It used to be (in a browser) that when you logged in, you were taken to a landing page with a unique "rowid" in the in URL. Once you knew that rowid, you could simply go to that page, and bypass the login process. Not very secure...but easy to scrape! Now, when you login, you are assigned a random rowid. Using the Firefox Deveoloper Tools, I see that there is NO cookie associated with the login. The rowid is now set in the form processing page. In the Developer Tools, this is seen in the Params...Query String section. How can I extract these params (rowid) from the form processing script, and proceed to the landing page...with the rowid in the Curl command? This just returns me to the login page..since the rowid isn't set. Thanks! $url = 'http://domain.com/formprocessing.html'; $fields = array( 'username' => urlencode('xxx'), 'password' => urlencode('xxx') ); $fields_string = ''; foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch);
  7. I have a given date on a webpage, that I'm scraping to insert into a DB. The date is in this format: Sun, Feb 9<br />3:00 PM ET I need to insert this into the DB in this format: 2020-02-09 15:00:00 It will always be this year...How can I change this data to be inserted correctly? I'm trying this...and it's inserting as 1969 $date = 'Sun, Feb 9<br />3:00 PM ET': $healthy = array("<br />", " ET", "Sun.", "Mon.", "Tue.", "Wed.", "Thu", "Fri.", "Sat.", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $yummy = array(" ", "2020", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); $date = str_replace($healthy, $yummy, $date1); $start = date('Y-m-d H:i:s', strtotime("$date -120 minutes")); Thanks!
  8. I got it working...left the dollar sign out of the function call getplayer('qb1'); and then an if / elseif statement inside the function: if ($position == 'qb1') { $new_position = $qb1; } elseif ($position == 'qb2') { $new_position = $qb2; } Thanks....
  9. I've tried that...the echo of the sql shows the name is blank
  10. I have a php file with a bunch of variables declared. I now need a function to put data on a separate page that pulls variables from the required page. So, on the required page, I have a variable set like this: $qb1 = "John Doe"; The function on the new script is called like this: getplayer($qb1); I've tried this without the dollar sign in the function like this: getplayer(qb1); and then adding the $dollar sign in the rest of the function code...but it never populates the sql query correctly. I'm guessing this is a case for variable variables or something similar, but I don't know how to get the variable value from the required page. Any ideas? Thanks. Here's the code: <?php function getplayer($position) { // start function //$new_position = "$" . $position; $new_position = $position; $file = "their.php"; require "$file"; //echo $qb1; this displays the name John Doe...as $qb1 is declared in the required file $db_select_their = "bschultz_their"; $servername = "localhost"; $username = "user"; $password = "pass"; $dbname = "db_name"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM (select number as position_number, name as position_name, pronunciation as position_pronunciation, pos as position_pos, height as position_height, weight as position_weight, year as position_year, city as position_city, state as position_state, notes as position_notes FROM $db_select_their WHERE name = '$new_position') as position"; //$sql = "SELECT * FROM bschultz_their WHERE name = $new_position"; echo $sql; //exit; /* this displays this text... SELECT * FROM (select number as position_number, name as position_name, pronunciation as position_pronunciation, pos as position_pos, height as position_height, weight as position_weight, year as position_year, city as position_city, state as position_state, notes as position_notes FROM bschultz_their WHERE name = '') as position The name is empty */ $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "#: " . $position_number . " - Name: " . $position_name . ""; } } else { echo "0 results"; } } // end function getplayer("${$qb1}"); $conn->close(); ?>
  11. I'm replacing Wordpress with my own content management system. Wordpress is just too bloated for my liking. The url's for the mp3's are embedded into the stories. Our final Beaver Fever Friday of the year was yesterday. What a show. It's always nice to get to know these seniors over their careers. Here are the interviews if you missed them: Christa Benson - Track <a href="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/ChristaBenson.mp3">Christa Benson - Track</a><br /><br /> Cody Cook - MGolf <a href="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/CodyCook.mp3">Cody Cook - MGolf</a><br /><br /> There is NO VARIABLE in the database content. Here's what I need the code to look like Our final Beaver Fever Friday of the year was yesterday. What a show. It's always nice to get to know these seniors over their careers. Here are the interviews if you missed them: Christa Benson - Track<audio controls> <source src="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/ChristaBenson.mp3" type="audio/mpeg"> </audio> <br /><br /> Cody Cook - MGolf <audio controls> <source src="http:///beaverradionetwork.com/audio/1011/brnpodcasts/BFF2019/CodyCook.mp3" type="audio/mpeg"> </audio> <br /><br />
  12. I'm finally moving away from Wordpress. I've used a couple of different mp3 players in the past, and I need to figure out how to replace a link to an mp3 file or just some text with xxx.mp3 with an html5 audio player. The one plugin I used replaced all links with a player button...another plugin I used you only needed to have .mp3 at the end, and it would replace the text with a button player. I have a VERY hard time wrapping my head around regex. How can I accomplish these two scenarios with 1 regex? <a href=http://domain.com/soundfile1.mp3>Some File</a> and http://domain.com/soundfile1.mp3 Are both in the old Wordpress database. The plugin has a button to press to play the file. Both need to be replaced with this: <audio controls> <source src="http://domain.com/soundfile1.mp3" type="audio/mpeg"/> </audio>
  13. That class will work....thank you!
  14. 30 files in this directory
  15. All files are 128k constant. id3 tags are empty. That's how they're downloaded. I read that -k would force KB...but without it, $showsize was off from what right clicking the directory showed me for file size. Would it be better to get size of all files instead of directory size? Does du take into account the size of all files individually, or just the combined disk space used?
  16. I have a directory of mp3 files that I need to find out the combined length in minutes and seconds of all the audio files. The files are all 128kbps stereo mp3's. Here's what I have so far... <?php //connect to remote server (hostname, port) $connection = ssh2_connect('192.168.2.4', 22); //authenticate ssh2_auth_password($connection, 'username', 'password'); //execute remote command (replace /path/to/directory with absolute path) $stream = ssh2_exec($connection, 'du -k /remotedirectory'); stream_set_blocking($stream, true); //get the output $dirSize = stream_get_contents($stream); //show the output and close the connection $showsize = $dirSize; //echo $showsize; exit; $math = (($showsize * 1000) / 128); //without the /128 it shows 34308000...which is correct. the files are 128kbps //echo $math; exit; echo gmdate("i:s", $math); // shows 27:11 which is wrong...the actual total time of all of the files in the directory is 36:34 ...minutes and seconds fclose($stream); ?> Any ideas where I'm off in the logic of the math? Thanks.
  17. I used Wordpress. I want to bail on Wordpress. I've moved the Wordpress posts to a new database. I'm displaying the post on the page. Using Wordpress, I could have a post that read: This is a post. Here is an mp3 address. (with the address shown, no a href tages needed) The Wordpress plugin would the the url and display an html5 audio player on the site for that mp3. Another plugin would take a Youtube link and embed the movie in a player. I want to scrape, or parse, the database content...pull out the mp3 url's...and replace them with an html5 player.
  18. I posted this....http://forums.phpfreaks.com/topic/297984-multiple-regex-on-the-same-string/ If you don't want to read the original post, I'm trying to abandon Wordpress, but still use the functionality of a couple of plugins. Not seeing any responses tells me that maybe I should be barking up a different tree. Is it possible to parse a database post and look for a URL that is NOT inside an a href tag? I Googling, I didn't see anything in the simpledom examples about scraping for anything OUTSIDE of a tag. Thanks!
  19. Another option...update all the old wordpress posts with updated html5 player code. Any ideas on how to write that auto-update code?
  20. I'm trying to move away from a Wordpress site. The site used multiple plugins for taking Youtube URL's in a post and embedding a Youtube player. I have that part figured out. The old site also used a plugin to take an mp3 URL and change that to an html5 audio player. That's where I'm having some problems. I need to strip the [php] and [/php] tags from the Wordpress post...and replace them with correct open and close php tags. I want to remove all LINKS to mp3 files...and put a player in place. I also want to take all mp3 URL's...and put a player in place. One wrinkle...in some of the Wordpress posts, I have a php include of another file. In that included file are mp3 links. The following code somewhat works. It matches the third PATTERN correctly (mp3 LINK). The second PATTERN does NOT match (mp3 URL...no a href tags) Are the second and third PATTERNS conflicting? Can they both match the same thing? I don't know nearly enough about regex to know. Also, why isn't the second PATTERN matching a URL? Also, how can I handle the included file...since it doesn't appear to be matching those LINKS (the included file is in the Wordpress post content...do I need to run eval on that post BEFORE running the regex? If so, how do you store eval results in a variable for further processing? <?php $patterns = array(); $patterns[] = '#(https?://)(www.)(?:youtube(?:-nocookie)?\.com/(?:[^/\s]+/.+/|(?:v|e(?:mbed)?)/|[^?&\s]*[?&]v=)|youtu\.be/)([^"&?/ ]{11})#x'; $patterns[] = '((https?:\/\/)?(\w+?\.)+?(\w+?\/)+\w+?.(mp3|ogg))'; $patterns[] = "((?i)a\\s+[^>]*?href\\s?=[\\s'\"]+(.*?(mp3))['\"]+.*?[^<]*<\/a>)"; $replacements = array(); $replacements[] = '<iframe width="640" height="385" src="http://www.youtube.com/embed/\\3" frameborder="0" allowfullscreen></iframe>'; $replacements[] = '<a href="\\0" class="sm2_button">BRN</a>'; $replacements[] = '<a href="\\1" class="sm2_button">BRN</a>'; $newwithyoutube1 = str_replace("[php]","<?php ",$row['content']); $newwithyoutube2 = str_replace("[/php]"," ?>",$newwithyoutube1); $newwithyoutube3 = preg_replace($patterns, $replacements, $newwithyoutube2); $newwithyoutube4 = str_replace(' <<a', ' <a', $newwithyoutube3); //the third PATTERN is adding an extra < symbol...so remove it if (strpos($newwithyoutube4 ,'<br')) { eval('?>'.$newwithyoutube4.'<?php '); } else { $nlnewphrase = nl2br($newwithyoutube4); eval('?>' . $nlnewphrase . '<?php '); } ?> Thanks!
  21. That worked. THANK YOU! You have no idea how much I hate the formatting of regex!
  22. I'm trying to search a string for Youtube url's and mp3 url's...and replace each with a player. Here's the code: $patterns = array(); $patterns[0] = '#(http://)(www.)(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})#x'; $patterns[1] = '((https?:\/\/)?(\w+?\.)+?(\w+?\/)+\w+?.(mp3|ogg))'; $replacements = array(); $replacements[0] = '<iframe width="640" height="385" src="http://www.youtube.com/embed/\\3" frameborder="0" allowfullscreen></iframe>'; $replacements[1] = '<a id="m5" class="audio {skin:"green", autoPlay:false, addShadow:false,addGradientOverlay:true}" href="\\0">Beaver Radio Network</a>'; $brnpost = 'This is our story content. Here is the youtube link: <br /><br /> http://www.youtube.com/watch?v=qvwefWgIQhY <br /><br />Listen Here: http://beaverradionetwork.com/audio/1011/brnpodcasts/leonhardt_skaar_2015.mp3'; echo preg_replace($patterns, $replacements, $brnpost); If I run each Regex individually, it works. If I join them into the array, it takes part of the mp3 link...and puts it in the Youtube embed. Like this: This is our story content. Here is the youtube link: <br /><br /> <iframe width="640" height="385" src="http://www.youtube.com/embed/leonhardt_s" frameborder="0" allowfullscreen></iframe>kaar_2015.mp3</body> What am I doing wrong? Thanks!
  23. I am abandoning Wordpress after several years. I need to handle some plugin functionality though OUTSIDE of Wordpress. I currently have a plugin that takes a link to an mp3, and Wordpress displays an html5 audio player. I also have a plugin that takes a youtube link, and embeds that video in the post. I don't need any code (unless you'd like to show me)...but what functions should I be using to find those links...and then add in the other coding needed to achieve what the plugins did? I don't want to inlcude the Wordpress files and structure in every page just to be able to use the plugins with the new code. Here's what I currently have in the database: http://domain.com/link.mp3 Here's the code I need to add: <audio controls> <source src="http://domain.com/link.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio> And for Youtube: https://www.youtube.com/watch?v=qvwefWgIQhY Needs to be: <iframe width="420" height="315" src="https://www.youtube.com/embed/qvwefWgIQhY" frameborder="0" allowfullscreen></iframe> I've already pulled all the posts from the Wordpress database into the new database. Just looking for how to process the links in the new html layout. EDIT...after putting in the raw links...I see that this site already does what I want to achieve...so had to put them in code tags! Thanks!
  24. Nevermind...figured it out. I never knew you could stick variables in an echo that way. Learned TWO things today! Thanks again!
  25. Thanks...that did the trick! So that I can understand what's going on with this code...what is the significance of the {} brackets around the XML fields names?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.