Jump to content
php.lv forumi

Citas lapas parsing?


GuruEdzus

Recommended Posts

Sveiki visiem.

Vēlētos uzzināt, kā es varētu parsot citu lapu, lai iegūtu citas lapas contentu? Vēlams būtu ar javascript. Izmēģināju visādus variantus kā parsot, bet visu laiku met vienu un to pašu erroru.

Access to fetch at '' from origin '' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
GET https://lapa.lv net::ERR_FAILED
Uncaught (in promise) TypeError: Failed to fetch
    at <anonymous>:1:1

Ir kādam kādas idejas kā tomēr es varētu dabūt konkrētas lapas html dom? Precizējums - Vajadzētu tikai konkrētu elementu izdabūt no lapas

Paldies jau iepriekš :)

Link to comment
Share on other sites

  • GuruEdzus changed the title to Citas lapas parsing?
  • 2 weeks later...
  • 1 month later...

Vari lietot PHP lai fetčotu citas lapas saturu un to tālāk padot variablī frontendam. 

 

<?php
$source = file_get_contents('https://www.tvnet.lv');
?>

<script type="text/javascript">
  let tvnetSource = "<?php echo htmlspecialchars($source); ?>";
</script>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...