Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- function scrapePlayPilot() {
- var PlayPilotURL = document.getElementById('<%= txtPlayPilotURL.ClientID %>').value;
- console.log('PlayPilot URL entered:', PlayPilotURL);
- $.get(PlayPilotURL, function (data) {
- // Create a temporary element to parse the HTML content
- var tempElement = document.createElement('div');
- tempElement.innerHTML = data;
- // Find the anchor tag with IMDb URL
- var imdbAnchor = tempElement.querySelector('a.link[href*="imdb.com"]');
- if (imdbAnchor) {
- var imdbURL = imdbAnchor.href;
- console.log('Scraped IMDb URL:', imdbURL);
- var txtIMDbURL = document.getElementById('<%= txtIMDbURL.ClientID %>');
- if (txtIMDbURL && !txtIMDbURL.value) {
- // Only set the IMDb URL if the field is empty
- txtIMDbURL.value = imdbURL;
- }
- } else {
- console.log('IMDb URL not found in the PlayPilot page.');
- }
- // Find YouTube URLs based on their context
- var youtubeLinks = tempElement.querySelectorAll('a[href*="youtube.com"]');
- youtubeLinks.forEach(function (youtubeLink) {
- var parentElement = youtubeLink.parentElement;
- if (parentElement && parentElement.classList.contains('video-block')) {
- var youtubeURL = youtubeLink.href;
- console.log('Scraped YouTube URL:', youtubeURL);
- var txtTrailerURL = document.getElementById('<%= txtTrailerURL.ClientID %>');
- if (txtTrailerURL && !txtTrailerURL.value) {
- // Only set the YouTube URL if the field is empty
- txtTrailerURL.value = youtubeURL;
- }
- }
- });
- if (!txtTrailerURL.value) {
- console.log('YouTube URL not found on the PlayPilot page.');
- }
- });
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement